1、开发WSDL时,需要注意wsdl:portType与wsdl:binding中的operation关系;
如有一WSDL如下:
<wsdl:definitions ……> …… <wsdl:portType name="TESTWebService"> <wsdl:operation name="queryTestInfo"> <wsdl:input message="tns:QueryTestInfo" name="queryTestInfo" /> <wsdl:output message="tns:QueryTestInfoResponse" name="queryTestInfoResponse" /> </wsdl:operation> <wsdl:binding name="TESTWebService" type="tns:TESTWebService"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="queryTestInfo"> <soap:operation soapAction="queryTestInfo" style="document" /> <wsdl:input> <!-- name属性为空 --> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <!-- name属性为空 --> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> …… </wsdl:definitions>
以上的WSDL如使用dotNet中的wsdl.exe进行编译,会出现“R2718 A wsdl:binding
in a DESCRIPTION MUST have the same set of wsdl:operation
s as the wsdl:portType
to which it refers.”这个错误。原因在于dotNet在编译binding中的operation时,找不到与binding中的wsdl:input和wsdl:output相同名字的wsdl:port定义。解决上述问题(在JAVA中不会出现此问题),有两种方法:
(1)、删除wsdl:portType中的wsdl:input的name属性;
(2)、添加wsdl:portType中的wsdl:input的name属性到wsdl:binding中的wsdl:input的name属性;