. NET returns null based on WSDL generated client call service

Source: Internet
Author: User
Tags wsdl

Since the projects we do need to interact with other systems, we provide the WSDL document to the developers of other systems, and when we test today, a client called Java's Web server in C # based on WSDL, the simplest return string type gets the value null. However, if you generate a C # client directly based on the WSDL generated by the Web service, you can return the value normally. Comparing the WSDL document generated by the original WSDL document with the Web service, there is no difference between the found.

The client code generated using the Wsdl.exe and WSDL documents is later compared to the code generated by the Web service that references Java directly in the project. There is a difference in the return value attribute in the method that calls the Web service: The client code generated by the WSDL tool is [Return:System.Xml.Serialization.XmlElementAttribute (" Out ", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]; The client code that directly references the Web service is [return: System.Xml.Serialization.XmlElementAttribute ("Out")], directly remove form = System.Xml.Schema.XmlSchemaForm.Unqualified This property, The client invocation of the Java Web Service generated by the tool will also get the return value correctly.

System.Xml.Schema.XmlSchemaForm There are three values in this enumeration: None,qualified,unqualified, which means that elements and attribute forms are not specified in the schema, elements and attributes must be qualified with namespaces, Namespaces are not required to qualify elements and attributes. This property exists in cross-platform invocation if the WSDL document is not well designed, and may return a value of NULL. For example, the attributeFormDefault and elementFormDefault properties are not set in the <xsd:schema/> element in the WSDL, the default value is qualified. This allows a namespace to be delivered when a Web service is generated in Java. In the client generated by the WSDL tool in C #, the Form = System.Xml.Schema.XmlSchemaForm.Unqualified is added by default in each element of the Schem declaration, and when the Web service invoking Java gets the return value, The message is received without a namespace, so that the message format of both sides is inconsistent, resulting in the Get value is null.

In addition to setting the attributeFormDefault and elementFormDefault properties in <xsd:schema/> When designing the WSDL, you can also modify the client code, for example, directly in C # In the client code, cancel the form = System.Xml.Schema.XmlSchemaForm.Unqualified or set the qualified.

. NET returns null based on WSDL generated client call service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.