1 package userguide.clients; 2 3 import org.apache.axis2.Constants; 4 import org.apache.axis2.addressing.AddressingConstants; 5 import org.apache.axis2.addressing.EndpointReference; 6 import org.apache.axis2.clientapi.Call; 7 import org.apache.axis2.engine.AxisFault; 8 import org.apache.axis2.om.OMElement; 9 import org.apache.axis2.om.OMOutput; 10 11 import javax.xml.stream.XMLOutputFactory; 12 import javax.xml.stream.XMLStreamException; 13 import java.io.StringWriter ; 14 15 30 31 public class ClientForWebServiceWithModule { 32 private static EndpointReference targetEPR = new EndpointReference(AddressingConstants.WSA_TO, 33 "http://127.0.0.1:8080/axis2/services/MyServiceWithModule/echo"); 34 35 public static void main(String [] args) { 36 try { 37 OMElement payload = ClientUtil.getEchoOMElement(); 38 Call call = new Call(); 39 call.setTo(targetEPR); 40 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false); 41 42 OMElement result = (OMElement) call.invokeBlocking("echo", payload); 44 45 StringWriter writer = new StringWriter (); 46 result.serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(writer))); 47 writer.flush(); 48 49 System.out.println(writer.toString()); 50 51 } catch (AxisFault axisFault) { 52 axisFault.printStackTrace(); 53 } catch (XMLStreamException e) { 54 e.printStackTrace(); 55 } 56 } 57 } 58 | Popular Tags |