You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-user@ws.apache.org by "Liu, Hua (Maria)" <Hu...@xerox.com> on 2008/04/11 19:01:42 UTC

why wsdl2java uses input element name to name the corresponding method?

Hi,

 

I wrote a simple Math service which has only one method "add" taking two
integers and return the sum. In Math.wsdl, I defined the operation
"add", and it receives an input message which contains an element named
"addReq". I used "wsdl2java.bat -osgi mini -wsdl Math.wsdl" to generate
the skeleton code and the method is named as "addReq". 

 

Then I dig into the source code and found out that
ResourceInspector.java uses the input element name ("addReq") to name
the method in the java code:

private JavaMethod createJavaMethod(Element wsdl, Operation op)

    {

        JavaMethod method = new JavaMethod();

        method.setName(getInputName(op));

        .........

    }

This confuses me a lot. Would someone please help me?

 

Thanks,

Hua

 

 

 

This is the Math.wsdl.

<?xml version="1.0" encoding="utf-8"?>

<wsdl:definitions name="Math"
targetNamespace="http://www.xerox.com/test/Math"

                  xmlns:tns="http://www.xerox.com/test/Math"

                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"

 
xmlns:wsdl-soap="http://schemas.xmlsoap.org/wsdl/soap/"

                  xmlns:wsa="http://www.w3.org/2005/08/addressing">

  <wsdl:types>

    <xsd:schema elementFormDefault="qualified"
targetNamespace="http://www.xerox.com/test/Math">

      <xsd:element name="AddReq">

        <xsd:complexType>

          <xsd:sequence>

            <xsd:element name="firstNum" type="xsd:int" maxOccurs="1"
minOccurs="1"/>

            <xsd:element name="secondNum" type="xsd:int" maxOccurs="1"
minOccurs="1"/>

          </xsd:sequence>

        </xsd:complexType>

      </xsd:element>

      <xsd:element name="AddResponse" type="xsd:int"/>

    </xsd:schema>

  </wsdl:types>

  

  <wsdl:message name="AddInputMessage">

    <wsdl:part name="parameters" element="tns:AddReq"/>

  </wsdl:message>

  <wsdl:message name="AddOutputMessage">

    <wsdl:part name="result" element="tns:AddResponse"/>

  </wsdl:message>

  

  <wsdl:portType name="MathPortType">

    <wsdl:operation name="Add">

      <wsdl:input
wsa:Action="http://www.xerox.com/test/Math/AddParameters"
message="tns:AddInputMessage"/>

      <wsdl:output
wsa:Action="http://www.xerox.com/test/Math/AddResponse"
message="tns:AddOutputMessage"/>

    </wsdl:operation>

  </wsdl:portType>

 

  <wsdl:binding name="MathBinding" type="tns:MathPortType">

    <wsdl-soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>

    <wsdl:operation name="Add">

      <wsdl-soap:operation
soapAction="http://www.xerox.com/test/Math/Add"/>

      <wsdl:input>

        <wsdl-soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

      </wsdl:input>

      <wsdl:output>

        <wsdl-soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

      </wsdl:output>

    </wsdl:operation>

  </wsdl:binding>

 

  <wsdl:service name="MathService">

    <wsdl:port name="MathPort" binding="tns:MathBinding">

      <wsdl-soap:address location="http://localhost:8080/Math"/>

    </wsdl:port>

  </wsdl:service>

  

</wsdl:definitions>

 

This is the java skeleton generated.

 

package com.xerox.www.test.Math;

 

public interface IMyCapability

{

    String PREFIX = "tns";

 

    String NAMESPACE_URI = "http://www.xerox.com/test/Math";

 

    public int addReq(int firstNum, int secondNum) throws Exception;

 

}