Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中如何在kSOAP信封中设置正确的安全标头_Android_Netbeans_Https_Glassfish_Ksoap2 - Fatal编程技术网

在Android中如何在kSOAP信封中设置正确的安全标头

在Android中如何在kSOAP信封中设置正确的安全标头,android,netbeans,https,glassfish,ksoap2,Android,Netbeans,Https,Glassfish,Ksoap2,我正在开发一个Android应用程序,它调用一个运行在GlassFish 3.1服务器上的SOAP web服务。我使用NetBeans7开发了web服务。 在我的应用程序中,我使用kSOAP2库连接到服务器 连接使用SSL进行保护,在证书出现一些问题后,可以建立连接,因此现在我必须设置SOAP信封的正确安全标头,否则我将在服务器上获得WssSoapFaultException:Invalid security header异常。问题是,我不知道安全头应该是什么样子 从这篇文章中我知道如何设置标题

我正在开发一个Android应用程序,它调用一个运行在GlassFish 3.1服务器上的SOAP web服务。我使用NetBeans7开发了web服务。 在我的应用程序中,我使用kSOAP2库连接到服务器

连接使用SSL进行保护,在证书出现一些问题后,可以建立连接,因此现在我必须设置SOAP信封的正确安全标头,否则我将在服务器上获得WssSoapFaultException:Invalid security header异常。问题是,我不知道安全头应该是什么样子

从这篇文章中我知道如何设置标题

我试图从GlassFish管理工具中获得一些关于标题外观的信息,但找不到任何信息

那么,我可以在web服务文件中的哪里找到这些信息,或者直接从生成的WSDL文件中获取这些信息

这就是我的WDSL文件的外观

编辑: 我意识到,在NetBeans中的web服务属性(右键单击ws->编辑web服务属性)中,在安全服务下,我选择了相互证书安全性。我不知道这是怎么发生的,我确信我在创建web服务时检查了传输安全性(SSL)。无论如何,我把它放回了传输安全性,现在WSDL文件更轻了。但是仍然需要安全标头,因此我遇到了与以前相同的问题

 <!--
 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. 
-->
<!--
 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. 
-->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://stawebservice.staws.stapf.de/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://stawebservice.staws.stapf.de/" name="stawebservice">
<wsp:Policy xmlns:wsapw3c="http://www.w3.org/2006/05/addressing/wsdl" wsu:Id="stawebservicePortBinding_Wsaw_Addressing_Policy-stawebservicePortBinding_WSAM_Addressing_Policy-stawebservicePortBinding_WSAM_Addressing_Policy">
<wsapw3c:UsingAddressing wsp:Optional="true"/>
<wsam:Addressing wsp:Optional="true">
<wsp:Policy/>
</wsam:Addressing>
</wsp:Policy>
<wsp:Policy xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" wsu:Id="stawebservicePortBindingPolicy">
<sp:TransportBinding>
<wsp:Policy>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic128/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:IncludeTimestamp/>
<sp:Layout>
<wsp:Policy>
<sp:Lax/>
</wsp:Policy>
</sp:Layout>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
</wsp:Policy>
</sp:TransportBinding>
<sp:Wss10/>
<wsam:Addressing/>
</wsp:Policy>
<types>
<xsd:schema>
<xsd:import namespace="http://stawebservice.staws.stapf.de/" schemaLocation="https://192.168.1.214:8181/STAwebservice_ssl/stawebservice?xsd=1"/>
</xsd:schema>
</types>
<message name="getPublicKey">
<part name="parameters" element="tns:getPublicKey"/>
</message>
<message name="getPublicKeyResponse">
<part name="parameters" element="tns:getPublicKeyResponse"/>
</message>
<message name="login">
<part name="parameters" element="tns:login"/>
</message>
<message name="loginResponse">
<part name="parameters" element="tns:loginResponse"/>
</message>
<message name="getOTP_HTTPS">
<part name="parameters" element="tns:getOTP_HTTPS"/>
</message>
<message name="getOTP_HTTPSResponse">
<part name="parameters" element="tns:getOTP_HTTPSResponse"/>
</message>
<message name="getOTP_SMS">
<part name="parameters" element="tns:getOTP_SMS"/>
</message>
<message name="getOTP_SMSResponse">
<part name="parameters" element="tns:getOTP_SMSResponse"/>
</message>
<message name="confirmOTP">
<part name="parameters" element="tns:confirmOTP"/>
</message>
<message name="confirmOTPResponse">
<part name="parameters" element="tns:confirmOTPResponse"/>
</message>
<portType name="stawebservice">
<operation name="getPublicKey">
<input wsaw:Action="http://stawebservice.staws.stapf.de/stawebservice/getPublicKeyRequest" wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/getPublicKeyRequest" message="tns:getPublicKey"/>
<output wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/getPublicKeyResponse" message="tns:getPublicKeyResponse"/>
</operation>
<operation name="login">
<input wsaw:Action="http://stawebservice.staws.stapf.de/stawebservice/loginRequest" wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/loginRequest" message="tns:login"/>
<output wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/loginResponse" message="tns:loginResponse"/>
</operation>
<operation name="getOTP_HTTPS">
<input wsaw:Action="http://stawebservice.staws.stapf.de/stawebservice/getOTP_HTTPSRequest" wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/getOTP_HTTPSRequest" message="tns:getOTP_HTTPS"/>
<output wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/getOTP_HTTPSResponse" message="tns:getOTP_HTTPSResponse"/>
</operation>
<operation name="getOTP_SMS">
<input wsaw:Action="http://stawebservice.staws.stapf.de/stawebservice/getOTP_SMSRequest" wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/getOTP_SMSRequest" message="tns:getOTP_SMS"/>
<output wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/getOTP_SMSResponse" message="tns:getOTP_SMSResponse"/>
</operation>
<operation name="confirmOTP">
<input wsaw:Action="http://stawebservice.staws.stapf.de/stawebservice/confirmOTPRequest" wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/confirmOTPRequest" message="tns:confirmOTP"/>
<output wsam:Action="http://stawebservice.staws.stapf.de/stawebservice/confirmOTPResponse" message="tns:confirmOTPResponse"/>
</operation>
</portType>
<binding name="stawebservicePortBinding" type="tns:stawebservice">
<wsaw:UsingAddressing/>
<wsp:PolicyReference URI="#stawebservicePortBinding_Wsaw_Addressing_Policy-stawebservicePortBinding_WSAM_Addressing_Policy-stawebservicePortBinding_WSAM_Addressing_Policy"/>
<wsp:PolicyReference URI="#stawebservicePortBindingPolicy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getPublicKey">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="getOTP_HTTPS">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="getOTP_SMS">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="confirmOTP">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="stawebservice">
<port name="stawebservicePort" binding="tns:stawebservicePortBinding">
<soap:address location="https://192.168.1.214:8181/STAwebservice_ssl/stawebservice"/>
</port>
</service>
</definitions>