When we use web service to provide interface services externally, many interfaces may return complex types, such as arrays. net and our assp api [alisoft SaaS platform API] under the WCF joint debugging, you will find the problem; if you want to make the Web Service released through the WSDL have the maximum compatibility, it is best to refer to the WS-I [Web Services Interoperability] standard, rather than just limited to the soap standard; the following will discuss the problem of returned array;
One of the assp api interfaces is getusinguser, and the returned object is an array. The array element is also a complex object simpleuserinfo, which includes two attributes: userid and username. When the WSDL declares this typeSoapenc: array is used by default.This is also the method in the SOAP specification; its declaration part is as follows:
<Xs: complextype name = "arrayofsimpleuserinfo">
<Xs: complexcontent>
<Xs: Restriction base = "soapenc: array">
<Xs: attribute ref = "soapenc: arraytype" WSDL: arraytype = "NS1: simpleuserinfo []"> </Xs: attribute>
</Xs: Restriction>
</Xs: complexcontent>
</Xs: complextype>
This declaration method is fine when it is associated with most client languages, such as Java ,. net WSE 2.0 ,. net WSE 3.0 and PHP; however, a problem occurs when using WCF for joint debugging. The result is as follows: 1) The service fails to be added through add service reference in vs2008, the generated proxy class is empty. 2) If svcutil is generated using the command line tool, an error message is displayed:
System. servicemodel. description. xmlserializermessagecontractimporter
Error: The reference type "http://schemas.xmlsoap.org/soap/encoding/:array”" is only valid for the corresponding soap.
After investigation, the above problems areDue to soapenc: The declaration method of array, the compatibility of this method in the SOAP specification is very poor, which has been highlighted in the WS-I BP [WS-I basic profile]After modification to the unbounded mode, the test passes. The modified declaration method is as follows:
<Xs: complextype name = "arrayofsimpleuserinfo">
<Xs: sequence>
<Xs: Element maxoccurs = "unbounded" minoccurs = "0" name = "simpleuserinfo" nillable = "true" type = "NS1: simpleuserinfo"/>
</Xs: sequence>
</Xs: complextype>
Soapenc: After the array problem is solved, the joint debugging in the WCF environment is not completely successful, but a little bit more. After the WSDL declaration is modified, it is normal to add service reference in vs2008, the ws on the server is also normal, and the normal results are returned in responsexml. However, the results parsed by the WCF for responsexml are incorrect. The USERID is null and the username is normal, is the userid information lost! After being verified by Ms personnelThe order of attribute information in simpleuserinfo declared in WSDL is inconsistent with that in soap responsexml.! To prevent isV from modifying the code generated by the client, we had to modify the sequence of userid and username in the server WSDL, And then solve all the problems;
To sum up, although Web services are completely cross-platform, there are still many incompatibility problems in the actual development process. This is not only due to the coding of developers, even some standards and norms are flawed, it does not mean that there is no problem to follow the soap standards and norms, as for this, we can refer to the WS-I standards, he pointed out many measures and methods to ensure maximum compatibility, which is very useful;
PS: The following lists the Reference Links.
WS-I basic overview English version: http://www.ibm.com/developerworks/cn/webservices/ws-ibaseprof1.0/index.html
WS-I Official Website: http://www.ws-i.org/
WSDL: http://www.w3.org/TR/wsdl.html