简体   繁体   中英

Axis2 service and primitive parameters (issue with C# client)

I deployed "hello world" service (Tomcat + Axis2):

public class ServerLogic {
    public int add(int x, int y) {
        return x + y;
    }
}

But Axis2 generated WSDL like this:

<xs:element name="add">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" name="x" type="xs:int"/>
            <xs:element minOccurs="0" name="y" type="xs:int"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="addResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" name="return" type="xs:int"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

When I generated C# client by this WSDL, I got method with this signature:

 void add(int x, [System.Xml.Serialization.XmlIgnoreAttribute()] bool xSpecified,
          int y, [System.Xml.Serialization.XmlIgnoreAttribute()] bool ySpecified,
out int @return, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool returnSpecified);

As I understand, *Specified -parameters - it's result of minOccurs="0" . So, how I can say to Axis2 to remove this minOccurs="0" from generated WSDL?

You can generate a WSDL file and then customize it.

For generate the WSDL file you can use Axis2's Java2WSDL as specified here: http://axis.apache.org/axis2/java/core/docs/quickstartguide.html#ready (full reference here: http://axis.apache.org/axis2/java/core/docs/reference.html )

You can also generate a wsdl file using Apache Ant as in the quickstart example: http://axis.apache.org/axis2/java/core/docs/quickstartguide.html#deploy .

The customized WSDL file must be placed in the META-INF folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM