tags:

views:

34

answers:

1

are there any approaches for leveraging a java interface file to call an axis web service w/o generating a stub class? We control both sides (client and server).

+1  A: 

Yes, you can use an "adhoc" client using org.apache.axis2.client.ServiceClient. It looks something like this.

import org.apache.axis2.client.ServiceClient;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import java.net.URL;


...
String endpoint = "http://wsendpoint.com/ServiceName"
 QName operation = new QName("http://namespace","WsRequest");               
             OMElement payload = buildPayload("requestdata");


 try{
                   ServiceClient sender= new ServiceClient(
                            null,
                            new URL(endpoint),
                            null,
                            null);
                   OMElement result = sender.sendReceive(operation,payload);
           logger.debug("response is:" + result.toString());                                   

                    }

             }catch (Exception e)  {
                 logger.debug("exception caught: " + e.getMessage());
             }
nont