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.namespace.QName ; 12 import javax.xml.stream.XMLOutputFactory; 13 import java.io.StringWriter ; 14 15 21 public class EchoBlockingDualClient { 22 private static EndpointReference targetEPR = new EndpointReference(AddressingConstants.WSA_TO, 23 "http://127.0.0.1:8080/axis2/services/MyService/echo"); 24 25 public static void main(String [] args) { 26 try { 27 OMElement payload = ClientUtil.getEchoOMElement(); 28 29 Call call = new Call(); 30 call.setTo(targetEPR); 31 32 call.engageModule(new QName (Constants.MODULE_ADDRESSING)); 35 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, true); 36 37 OMElement result = (OMElement) call.invokeBlocking("echo", payload); 39 40 StringWriter writer = new StringWriter (); 41 result.serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(writer))); 42 writer.flush(); 43 44 System.out.println(writer.toString()); 45 46 call.close(); 48 49 } catch (AxisFault axisFault) { 50 axisFault.printStackTrace(); 51 } catch (Exception ex) { 52 ex.printStackTrace(); 53 } 54 55 } 56 } 57 | Popular Tags |