wsdl如下(jboss服务器的):
<?xml version="1.0" encoding="UTF-8" ?>
- <definitions name="TestServiceService" targetNamespace="http://service.com/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <types>
- <xs:schema targetNamespace="http://service.com/" version="1.0" xmlns:tns="http://service.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test" type="tns:test" />
<xs:element name="testResponse" type="tns:testResponse" />
- <xs:complexType name="test">
- <xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string" />
<xs:element minOccurs="0" name="arg1" type="xs:string" />
</xs:sequence>
</xs:complexType>
- <xs:complexType name="testResponse">
- <xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
- <message name="TestService_test">
<part element="tns:test" name="test" />
</message>
- <message name="TestService_testResponse">
<part element="tns:testResponse" name="testResponse" />
</message>
- <portType name="TestService">
- <operation name="test" parameterOrder="test">
<input message="tns:TestService_test" />
<output message="tns:TestService_testResponse" />
</operation>
</portType>
- <binding name="TestServiceBinding" type="tns:TestService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="test">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="TestServiceService">
- <port binding="tns:TestServiceBinding" name="TestServicePort">
<soap:address location="http://127.0.0.1:8080/WebService/TestService" />
</port>
</service>
</definitions>
在这里和C#中的不同处在:
java:<xs:element name="test" type="tns:test" />
c#:
<s:element name="test">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
比如js调用c#时:
var sr =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<test xmlns=\"http://service.com/\">" +
"<name>a</name><password>bpassword>"+
"</test>"+
"</soap:Body></soap:Envelope>";
可以正常调用,如果调用java的时,传递参数始终没传正确,不传参数,不报错可以正常调用,参数的值为NULL,
请问:根据这个java的wsdl文档,怎么写传参数的SOAP包?
<?xml version="1.0" encoding="UTF-8" ?>
- <definitions name="TestServiceService" targetNamespace="http://service.com/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <types>
- <xs:schema targetNamespace="http://service.com/" version="1.0" xmlns:tns="http://service.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test" type="tns:test" />
<xs:element name="testResponse" type="tns:testResponse" />
- <xs:complexType name="test">
- <xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string" />
<xs:element minOccurs="0" name="arg1" type="xs:string" />
</xs:sequence>
</xs:complexType>
- <xs:complexType name="testResponse">
- <xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
- <message name="TestService_test">
<part element="tns:test" name="test" />
</message>
- <message name="TestService_testResponse">
<part element="tns:testResponse" name="testResponse" />
</message>
- <portType name="TestService">
- <operation name="test" parameterOrder="test">
<input message="tns:TestService_test" />
<output message="tns:TestService_testResponse" />
</operation>
</portType>
- <binding name="TestServiceBinding" type="tns:TestService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="test">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="TestServiceService">
- <port binding="tns:TestServiceBinding" name="TestServicePort">
<soap:address location="http://127.0.0.1:8080/WebService/TestService" />
</port>
</service>
</definitions>
在这里和C#中的不同处在:
java:<xs:element name="test" type="tns:test" />
c#:
<s:element name="test">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
比如js调用c#时:
var sr =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<test xmlns=\"http://service.com/\">" +
"<name>a</name><password>bpassword>"+
"</test>"+
"</soap:Body></soap:Envelope>";
可以正常调用,如果调用java的时,传递参数始终没传正确,不传参数,不报错可以正常调用,参数的值为NULL,
请问:根据这个java的wsdl文档,怎么写传参数的SOAP包?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货