You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Pauli Savolainen <sa...@gmail.com> on 2009/01/05 17:22:01 UTC

Axis2/jax-ws unmarshal response

Hi,

I use wsimport to generate classes from my wsdl. My webservice has one
method called getVersion. I call this webservice and all works fine except
when the response is unmarshalled into a java object the return value
disappears.


WebService class

@WebService(name = "Version", targetNamespace = "mynamespace")
@XmlSeeAlso({
    ObjectFactory.class
})
@SOAPBinding(parameterStyle = ParameterStyle.BARE)
public interface Event {
 ...
 String getVersion()
}


Client:

VersionService service = new VersionService();
Version version = service.getPort(Version.class);
System.out.println(version.getVersion());
--> null

The response message:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getVersionResponse xmlns:ns="mynamespace">
<ns:return>VERSION</ns:return>
</ns:getVersionResponse>
</soapenv:Body>
</soapenv:Envelope>

The unmarshalled object has a string field response but it is always null.
If I change the SOAPBinding annotation parameterStyle.BARE to
parameterStyle.WRAPPED I get the correct answer but this I shouldn't do
because the elements in my wsdl are not really wrappers (according to the
jax-ws spec).

If I change the elements to properly wrapped (according to the spec), I
still get the null result when calling the getVersion method of the
webservice.

So no matter what I do I the unmarshalled object's field is always null even
though I clearly see that there is stuff in the response. Why is this? Could
it be that the ns:return element screws something up in the unmarshalling
process.

Thank you

Pauli


-- 
View this message in context: http://www.nabble.com/Axis2-jax-ws-unmarshal-response-tp21294027p21294027.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2/jax-ws unmarshal response

Posted by Pauli Savolainen <sa...@gmail.com>.
Hello,

issue solved. I was using the wrong message receiver. Instead of
org.apache.axis2.rpc.receivers.RPCMessageReceiver I am supposed to use the
org.apache.axis2.jaxws.server.JAXWSMessageReceiver. How silly of me.

Pauli
-- 
View this message in context: http://www.nabble.com/Axis2-jax-ws-unmarshal-response-tp21294027p21307265.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2/jax-ws unmarshal response

Posted by Pauli Savolainen <sa...@gmail.com>.
Hello,

Strike the previous code example out. Here is a more complete extract of my
code.

schema.xsd

<xsd:schema ...>
  <xsd:element name="getVersion">
    <xsd:complexType>
      <xsd:sequence>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  
  <xsd:element name="getVersionResponse">
    <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="version" type="xsd:string"></xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>



wsdl - simplified

<wsdl:definitions name="VersionService" ...>

  <!-- TYPES -->
  <wsdl:types>
	<xsd:schema ... >
      <xsd:include schemaLocation="schema.xsd"></xsd:include>
    </xsd:schema>
  <wsdl:types>

  <!-- MESSAGES -->
  <wsdl:message name="versionRequest">
    <wsdl:part element="schema:getVersion" name="versionRequest"/>
  </wsdl:message>
  <wsdl:message name="versionResponse"  >
    <wsdl:part element="schema:getVersionResponse" name="versionResponse"/>
  </wsdl:message>

  <!-- PORT -->
  <wsdl:portType name="Version">
    <wsdl:operation  name="getVersion">
      <wsdl:input message="event:versionRequest"></wsdl:input>
      <wsdl:output message="event:versionResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <!-- BINDING -->
  <wsdl:binding name="VersionSoapBinding" type="event:Event">
    <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <!-- Service -->
    <wsdl:operation name="getVersion">
      <soap:operation soapAction="mynamespace/VersionService/getVersion"/>
      <wsdl:input><soap:body use="literal"/></wsdl:input>
      <wsdl:output><soap:body use="literal"/></wsdl:output>
    </wsdl:operation>
  </wsdl:binding>


  <!-- SERVICE -->
  <wsdl:service name="VersionService">
    <wsdl:port name="Version" binding="event:VersionSoapBinding">
      <soap:address
location="http://localhost:8080/axis2/services/VersionService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


services.xml

<serviceGroup> 
  <service name="VersionService">
    <messageReceivers>
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
        class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter locked="false" name="ServiceClass">
      VersionPort
    </parameter>
  </service>
</serviceGroup>

wsimport generated service interface

@WebService(name = "Version", targetNamespace =
"mynamespace/VersionService")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface Version {

    @WebMethod(action = "mynamespace/VersionService/getVersion")
    @WebResult(name = "version", targetNamespace = "schema")
    @RequestWrapper(localName = "getVersion", targetNamespace = "schema",
className = "GetVersion")
    @ResponseWrapper(localName = "getVersionResponse", targetNamespace =
"schema", className = "GetVersionResponse")
    public String getVersion();
}

My implementation of the class just has the method getVersion which returns
"VERSION". The method does get called.

The client code looks like this. It always prints null. If I do some
debugging I see that the return value is present, but the unmarshalled
object (version) does not have it.

VersionService service = new VersionService();
Version version = service.getPort(Version.class); // Port
System.out.println(version.getVersion());

My question is what am I doing wrong? I must be doing something wrong, but I
have run out of ideas. I suspect it has got something to do with how I
configure the whole thing. Maybe I use wrong kind style in my binding
(document/rpc). Does it have much effect? Could it be in my schema? All the
examples I see online look quite similar to mine, but for some reason I
can't see the return value in the version-object.

Thank you

Pauli




Pauli Savolainen wrote:
> 
> Hi,
> 
> I use wsimport to generate classes from my wsdl. My webservice has one
> method called getVersion. I call this webservice and all works fine except
> when the response is unmarshalled into a java object the return value
> disappears.
> 
> 
> WebService class
> 
> @WebService(name = "Version", targetNamespace = "mynamespace")
> @XmlSeeAlso({
>     ObjectFactory.class
> })
> @SOAPBinding(parameterStyle = ParameterStyle.BARE)
> public interface Event {
>  ...
>  String getVersion()
> }
> 
> 
> Client:
> 
> VersionService service = new VersionService();
> Version version = service.getPort(Version.class);
> System.out.println(version.getVersion());
> --> null
> 
> The response message:
> 
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Body>
> <ns:getVersionResponse xmlns:ns="mynamespace">
> <ns:return>VERSION</ns:return>
> </ns:getVersionResponse>
> </soapenv:Body>
> </soapenv:Envelope>
> 
> The unmarshalled object has a string field response but it is always null.
> If I change the SOAPBinding annotation parameterStyle.BARE to
> parameterStyle.WRAPPED I get the correct answer but this I shouldn't do
> because the elements in my wsdl are not really wrappers (according to the
> jax-ws spec).
> 
> If I change the elements to properly wrapped (according to the spec), I
> still get the null result when calling the getVersion method of the
> webservice.
> 
> So no matter what I do I the unmarshalled object's field is always null
> even though I clearly see that there is stuff in the response. Why is
> this? Could it be that the ns:return element screws something up in the
> unmarshalling process.
> 
> Thank you
> 
> Pauli
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Axis2-jax-ws-unmarshal-response-tp21294027p21306108.html
Sent from the Axis - User mailing list archive at Nabble.com.