You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Dzmitry Rakavets <Dz...@epam.com> on 2008/12/02 17:57:17 UTC

Problem with Tuscany calling an AXIS2 web service

Hello, 

I'm trying to investigate Tuscany possibilities to work with external web services (for example, provided by AXIS).

I created a very simple AXIS2 web service, which is deployed as POJO on Tomcat. Here is the interface it provides:

public interface DemoService {

    public void voidMethod();

    public void voidMethodWithParams(int param1, String param2, BigDecimal param3);

    public String echoMethod(String value);

    public String paramStructureMethod(samples.quickstart.service.pojo.DemoParamStructure structure);

    public samples.quickstart.service.pojo.DemoParamStructure resultStructureMethod(int param1, String param2, BigDecimal param3);
}

samples.quickstart.service.pojo.DemoParamStructure is a simple java bean:

public class DemoParamStructure {

    private int integerParam;

    private String stringParam;

    private BigDecimal decimalParam;

    // ... getters and setters
}

At Tuscany side, I created a reference to this web service and placed WSDL file generated by AXIS somewhere under Tuscany domain:

<reference name="stub">
    <interface.java interface="com.sample.tuscany.test.DemoServiceStub"/>
    <binding.ws wsdlElement="http://pojo.service.quickstart.samples#wsdl.port(DemoService/DemoServiceHttpSoap11Endpoint)"/>
</reference>

The first 4 methods worked fine, however I was not able to get the correct result from the last method, which returned java bean as a result. I created the same java bean class (samples.quickstart.service.pojo.DemoParamStructure) at Tuscany side and used this class in reference interface:

@Remotable
public interface DemoServiceStub {

    @Oneway
    public void voidMethod();

    @Oneway
    public void voidMethodWithParams(int param1, String param2, BigDecimal param3);

    public String echoMethod(String value);

    public String paramStructureMethod(samples.quickstart.service.pojo.DemoParamStructure structure);

    public samples.quickstart.service.pojo.DemoParamStructure resultStructureMethod(int param1, String param2, BigDecimal param3);
}

What I got from calling DemoServiceStub.resultStructureMethod(...) method was the instance of samples.quickstart.service.pojo.DemoParamStructure class with EMPTY private fields. SOAP monitor showed the following SOAP result message, which had values provided for every field:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
    <ns:resultStructureMethodResponse xmlns:ns="http://pojo.service.quickstart.samples">
        <ns:return xmlns:ax23="http://pojo.service.quickstart.samples/xsd" type="samples.quickstart.service.pojo.DemoParamStructure">
            <ax23:decimalParam>3</ax23:decimalParam>
            <ax23:integerParam>1</ax23:integerParam>
            <ax23:stringParam>2</ax23:stringParam>
        </ns:return>
    </ns:resultStructureMethodResponse>
</soapenv:Body>
</soapenv:Envelope>

I am not an experienced web service developer, so most probably I missed something... It looks like XML to Java mapping is not working correctly in my case and skips values for private fields.

I also generated AXIS2 client using ADB and it worked fine. The result SOAP message was almost the same, except that it used http://www.w3.org/2003/05/soap-envelope namespace which seems to be OK since AXIS2 client uses SOAP 1.2.

Can you please advice?

Thanks and kind regards,
Dzmitry

Re: Problem with Tuscany calling an AXIS2 web service

Posted by Raymond Feng <en...@gmail.com>.
Hi,

Tuscany follows the JAXWS/JAXB default Java/XML mapping rules for JavaBeans. 
For DemoParamStructure bean, the corresponding XML elements for the 
properties should not be qualified (i.e., <decimalParam> instead of 
<ax23:decimalParam>, see the xml below). Because the client side receives 
qualified XML elements and JAXB databinding fails to populate the 
DemoParamStructure.

<ns:return xmlns:ax23="http://pojo.service.quickstart.samples/xsd">
     <decimalParam>3</decimalParam>
     <integerParam>1</integerParam>
     <stringParam>2</stringParam>
</ns:return>

It seems that Axis2 uses different mapping rules for JavaBeans. It's also 
interesting that Axis2 produces an attribute: 
type="samples.quickstart.service.pojo.DemoParamStructure".

Can you try to annotate DemoParamStructure with JAXB annotations (such as 
@XmlElement) to make sure the Java/XML mapping is accurate. One thing you 
can try is to use "wsimport" to generate the Java classes out of the WSDL to 
see how it looks like.

Thanks,
Raymond
--------------------------------------------------
From: "Dzmitry Rakavets" <Dz...@epam.com>
Sent: Tuesday, December 02, 2008 8:57 AM
To: <us...@tuscany.apache.org>
Subject: Problem with Tuscany calling an AXIS2 web service

> Hello,
>
> I'm trying to investigate Tuscany possibilities to work with external web 
> services (for example, provided by AXIS).
>
> I created a very simple AXIS2 web service, which is deployed as POJO on 
> Tomcat. Here is the interface it provides:
>
> public interface DemoService {
>
>    public void voidMethod();
>
>    public void voidMethodWithParams(int param1, String param2, BigDecimal 
> param3);
>
>    public String echoMethod(String value);
>
>    public String 
> paramStructureMethod(samples.quickstart.service.pojo.DemoParamStructure 
> structure);
>
>    public samples.quickstart.service.pojo.DemoParamStructure 
> resultStructureMethod(int param1, String param2, BigDecimal param3);
> }
>
> samples.quickstart.service.pojo.DemoParamStructure is a simple java bean:
>
> public class DemoParamStructure {
>
>    private int integerParam;
>
>    private String stringParam;
>
>    private BigDecimal decimalParam;
>
>    // ... getters and setters
> }
>
> At Tuscany side, I created a reference to this web service and placed WSDL 
> file generated by AXIS somewhere under Tuscany domain:
>
> <reference name="stub">
>    <interface.java interface="com.sample.tuscany.test.DemoServiceStub"/>
>    <binding.ws 
> wsdlElement="http://pojo.service.quickstart.samples#wsdl.port(DemoService/DemoServiceHttpSoap11Endpoint)"/>
> </reference>
>
> The first 4 methods worked fine, however I was not able to get the correct 
> result from the last method, which returned java bean as a result. I 
> created the same java bean class 
> (samples.quickstart.service.pojo.DemoParamStructure) at Tuscany side and 
> used this class in reference interface:
>
> @Remotable
> public interface DemoServiceStub {
>
>    @Oneway
>    public void voidMethod();
>
>    @Oneway
>    public void voidMethodWithParams(int param1, String param2, BigDecimal 
> param3);
>
>    public String echoMethod(String value);
>
>    public String 
> paramStructureMethod(samples.quickstart.service.pojo.DemoParamStructure 
> structure);
>
>    public samples.quickstart.service.pojo.DemoParamStructure 
> resultStructureMethod(int param1, String param2, BigDecimal param3);
> }
>
> What I got from calling DemoServiceStub.resultStructureMethod(...) method 
> was the instance of samples.quickstart.service.pojo.DemoParamStructure 
> class with EMPTY private fields. SOAP monitor showed the following SOAP 
> result message, which had values provided for every field:
>
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Body>
>    <ns:resultStructureMethodResponse 
> xmlns:ns="http://pojo.service.quickstart.samples">
>        <ns:return xmlns:ax23="http://pojo.service.quickstart.samples/xsd" 
> type="samples.quickstart.service.pojo.DemoParamStructure">
>            <ax23:decimalParam>3</ax23:decimalParam>
>            <ax23:integerParam>1</ax23:integerParam>
>            <ax23:stringParam>2</ax23:stringParam>
>        </ns:return>
>    </ns:resultStructureMethodResponse>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I am not an experienced web service developer, so most probably I missed 
> something... It looks like XML to Java mapping is not working correctly in 
> my case and skips values for private fields.
>
> I also generated AXIS2 client using ADB and it worked fine. The result 
> SOAP message was almost the same, except that it used 
> http://www.w3.org/2003/05/soap-envelope namespace which seems to be OK 
> since AXIS2 client uses SOAP 1.2.
>
> Can you please advice?
>
> Thanks and kind regards,
> Dzmitry