axis2 web service behave differently when tested with web service client or with local test class

Posted by Stefano on Stack Overflow See other posts from Stack Overflow or by Stefano
Published on 2010-05-04T11:02:58Z Indexed on 2010/05/04 11:08 UTC
Read the original article Hit count: 972

Filed under:
|

Hello

I need to update a facade to some web service proxy classes to a third party web service, and expose them as a service. This for two reason : to maintain the same interface for all application that need to use the system : actually its migrating and there are a few differences in the third party ws (method names); and to expose a simplified interface.

The third party has provided me with a manual and some pregenerated proxy classes to their service (the java file says generated with axis2 1,4) . I've used netbeans 6.8 and the axis2 plugin to create an axis2 service . This service contains the proxy classes and the facade class which instantiate the web service proxy and calls its method; the facade class is exposed as service. I've used axis2 1.4 (at beginnig and later 1.5 ) and tomcat 6.0.
The first test i did was to call the facede methods from inside the project itself and it worked. Then i've created a new project with a jax-ws web service client to call my class deployed on axis2.

At this point has happened two strange thing :

  1. In the axis2 services page has appeared the third party proxy class as if it were a new service (if i try to get the wsdl axis raises an error ). eg. the proxy interface is named WebServiceAPI (_stub is the concrete class) and , after the first call to my service , i find a new "WebServicesAPI1272968932531_1" service inside axis . The call obvoiusly fail

  2. i've began to sniff soap messages with wireshark and i've found they differs when using proxy classes direclty from my facade test class by the messages created after being deployed on axis. i've noticed they differs for the presence of the soap header in the failing message.

any help would be greatly appreciated : maybe i messed up something, there might be some incompatibilities or version mistakes?

below i've added the signature of the third party proxy, its impementation and the different soap messages:

     /*
     * WebServicesAPI.java
     * This file was auto-generated from WSDL
     * by the Apache Axis2 version: 1.4  Built on : Apr 26, 2008 (06:24:30 EDT)
     */

        package com.ibm.eci.wsapi;

    public interface WebServicesAPI {

    public com.ibm.eci.wsapi.ArrayOfstring getWorkItemHistory(
    java.lang.String stateKey,java.lang.String logonID,com.ibm.eci.wsapi.RepoItemHandle workItemHandle) throws java.rmi.RemoteException,com.ibm.eci.wsapi.ExceptionException0;
...etc

the concrete class is :

    /**
     * WebServicesAPIStub.java
     *
     * This file was auto-generated from WSDL
     * by the Apache Axis2 version: 1.4  Built on : Apr 26, 2008 (06:24:30 EDT)
     */
            package com.ibm.eci.wsapi;



            /*
            *  WebServicesAPIStub java implementation
            */


            public class WebServicesAPIStub extends org.apache.axis2.client.Stub
            implements WebServicesAPI{
            protected org.apache.axis2.description.AxisOperation[] _operations;

            ...

            public  com.ibm.eci.wsapi.ArrayOfstring getWorkItemHistory(
            java.lang.String stateKey297,java.lang.String    
            logonID298,com.ibm.eci.wsapi.RepoItemHandle workItemHandle299)
            throws java.rmi.RemoteException                
                 ,com.ibm.eci.wsapi.ExceptionException0{
                  org.apache.axis2.context.MessageContext _messageContext = null;
                  try{
                   org.apache.axis2.client.OperationClient _operationClient = 
                     _serviceClient.createClient(_operations[0].getName());
                  _operationClient.getOptions().setAction("\"\"");
                  _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
                  addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&");
                  // create a message context
                  _messageContext = new org.apache.axis2.context.MessageContext();

                  // create SOAP envelope with that payload
                  org.apache.axiom.soap.SOAPEnvelope env = null;
                        com.ibm.eci.wsapi.GetWorkItemHistoryE dummyWrappedType = null;
                 env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
                                                        stateKey297,
                                                        logonID298,
                                                        workItemHandle299,
                                                        dummyWrappedType,
                                                        optimizeContent(new javax.xml.namespace.QName("http://wsapi.eci.ibm.com",
                                                        "getWorkItemHistory")));

            //adding SOAP soap_headers
             _serviceClient.addHeadersToEnvelope(env);
            // set the message context with that soap envelope
            _messageContext.setEnvelope(env);

            // add the message contxt to the operation client
            _operationClient.addMessageContext(_messageContext);

            //execute the operation client
            _operationClient.execute(true);
           org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
                                               org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                    org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
                                    java.lang.Object object = fromOM(
                                                 _returnEnv.getBody().getFirstElement() ,
com.ibm.eci.wsapi.GetWorkItemHistoryResponseE.class,
                                                  getEnvelopeNamespaces(_returnEnv));
                                            return getGetWorkItemHistoryResponse_return((com.ibm.eci.wsapi.GetWorkItemHistoryResponseE)object);
    ...

the failing soap message (generated by jax-ws client to the axis deployed service) is :

POST /vbr_wsapi/services/WebServicesAPI.Endpoint HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
User-Agent: Axis2
Host: n0611049:9083
Transfer-Encoding: chunked

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://n0611049:9083/vbr_wsapi/services/WebServicesAPI.Endpoint</wsa:To>
<wsa:MessageID>urn:uuid:A31AD99897F9045E981272964443982</wsa:MessageID><wsa:Action>""</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<ns1:initializeProps xmlns:ns1="http://wsapi.eci.ibm.com">
<props><val>client.locale=it_IT</val>
</props>
</ns1:initializeProps>
</soapenv:Body>
</soapenv:Envelope>

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Connection: Close
Date: Tue, 04 May 2010 09:16:15 GMT
Server: WebSphere Application Server/7.0

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://www.w3.org/2005/08/addressing/fault</wsa:Action>
<wsa:RelatesTo>urn:uuid:A31AD99897F9045E981272964443982</wsa:RelatesTo>
<wsa:FaultDetail>
<wsa:ProblemAction>
<wsa:Action>""</wsa:Action>
</wsa:ProblemAction>
</wsa:FaultDetail>
</soapenv:Header>
<soapenv:Body>
<soapenv:Fault xmlns:wsa="http://www.w3.org/2005/08/addressing">
<faultcode>wsa:ActionNotSupported</faultcode>
<faultstring>The [action] cannot be processed at the receiver.</faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

the succesful call (generated by my local test class, not being deployed to axis yet) :

POST /vbr_wsapi/services/WebServicesAPI.Endpoint HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
User-Agent: Axis2
Host: n0611049:9083
Transfer-Encoding: chunked

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:initializeProps xmlns:ns1="http://wsapi.eci.ibm.com">
<props>
<val>client.locale=it_IT</val>
</props>
</ns1:initializeProps>
</soapenv:Body>
</soapenv:Envelope>



HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Date: Tue, 04 May 2010 09:40:03 GMT
Server: WebSphere Application Server/7.0

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dlwmin:initializePropsResponse xmlns:dlwmin="http://wsapi.eci.ibm.com">
<return>e0e40cc51ceb0adf96c582bb6e047b3d0f</return>
</dlwmin:initializePropsResponse>
</soapenv:Body>
</soapenv:Envelope>

POST /vbr_wsapi/services/WebServicesAPI.Endpoint HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
User-Agent: Axis2
Host: n0611049:9083
Transfer-Encoding: chunked

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:logon xmlns:ns1="http://wsapi.eci.ibm.com">
<stateKey>e0e40cc51ceb0adf96c582bb6e047b3d0f</stateKey>
<systemID>----</systemID>
<authBundle>
<password>-----</password>
<sealed>false</sealed>
<username>---</username>
</authBundle>
</ns1:logon>
</soapenv:Body>
</soapenv:Envelope>



HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked
Date: Tue, 04 May 2010 09:40:21 GMT
Server: WebSphere Application Server/7.0


<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dlwmin:logonResponse xmlns:dlwmin="http://wsapi.eci.ibm.com">
<return>e0e40cc51ceb0adf96c582bb6e047b3d10</return>
</dlwmin:logonResponse>
</soapenv:Body>
</soapenv:Envelope>

... goes on with other calls 

© Stack Overflow or respective owner

Related posts about axis2

Related posts about netbeans6.8