views:

70

answers:

1

Hi,

I am trying to develop a web service with axis2. The problem is that I don't get the parameters passed in the url for an http Binding.

Here is my service.xml :

<parameter name="ServiceClass">my.package.MyClass
    </parameter>
    <operation name="getUser">
        <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
    </operation>
    <parameter name="useOriginalwsdl">true</parameter>

Here is my simplified wsdl :

<definitions ...>
        <types>
            <schema ...>
                <complexType name="User">
                    <sequence>
                        <element name="id" type="string"/>
                        <element name="age" type="int"/>
                    </sequence>
                </complexType>
                <element name="getUser">
                    <complexType>
                        <sequence>
                            <element name="id" type="xs:string" form="unqualified" />
                        </sequence>
                    </complexType>
                </element>
                <element name="getUserResponse">
                    <complexType>
                        <sequence>
                            <element name="user" nillable="true"
                                type="user" />
                        </sequence>
                    </complexType>
                </element>
            </schema>
        </types>


        <message name="getUserRequest">
            <part name="parameters" element="getUser" />
        </message>
        <message name="getUserResponse">
            <part name="parameters" element="getUserResponse" />
        </message>

        <portType name="testPortType">
            <operation name="getUser">
                <input message="getUserRequest"
                    Action="urn:getUser" />
                <output message="getUserResponse"
                    Action="urn:getUserResponse" />
            </operation>
        </portType>

        <binding name="testHttpBinding" type="testPortType">
            <binding verb="GET" />
            <operation name="getUser">
                <http:operation location="getUser" />
                <input>
                    <http:urlEncoded />
                <input>
                <output>
                    <mime:content type="text/xml" />
                </output>
            </operation>
        </binding>
        <service name="test">
            <port name="testHttpEndpoint" binding="testHttpBinding">
                <address
                    location="http://localhost:8080/axis2/services/test.testHttpEndpoint/" />
            </port>
        </service>
    </definitions>

and finally my.package.MyClass :

public final class MyClass {

 public User getUser(String id) {
  //Do something
 }
}

When I call the service with the request http://urlToService/getUser?id=test, I enter in getUser(String id) but the id is null.

Does someone know how am I supposed to fix that?

Thank you

A: 

In fact I was doing something wrong.

In MyClass, I am not supposed to do :

public User getUser(String id){
}

but

public User getUser(GetUser getUser){
}

as written in the wsdl file.