1 16 17 package org.apache.axis2.engine; 18 19 21 import javax.xml.namespace.QName ; 22 23 import junit.framework.TestCase; 24 25 import org.apache.axis2.Constants; 26 import org.apache.axis2.addressing.AddressingConstants; 27 import org.apache.axis2.addressing.EndpointReference; 28 import org.apache.axis2.context.MessageContext; 29 import org.apache.axis2.context.ServiceContext; 30 import org.apache.axis2.description.ServiceDescription; 31 import org.apache.axis2.integration.TestingUtils; 32 import org.apache.axis2.integration.UtilServer; 33 import org.apache.axis2.om.OMAbstractFactory; 34 import org.apache.axis2.om.OMElement; 35 import org.apache.axis2.om.OMNamespace; 36 import org.apache.axis2.soap.SOAPFactory; 37 import org.apache.axis2.util.Utils; 38 import org.apache.commons.logging.Log; 39 import org.apache.commons.logging.LogFactory; 40 41 public class ServiceDispatchingTest extends TestCase { 42 private EndpointReference targetEPR = 43 new EndpointReference( 44 AddressingConstants.WSA_TO, 45 "http://127.0.0.1:" 46 + (UtilServer.TESTING_PORT) 47 + "/axis/services/EchoXMLService/echoOMElement"); 48 private Log log = LogFactory.getLog(getClass()); 49 private QName serviceName = new QName ("EchoXMLService"); 50 private QName operationName = new QName ("echoOMElement"); 51 private QName transportName = new QName ("http://localhost/my", "NullTransport"); 52 53 private AxisConfiguration engineRegistry; 54 private MessageContext mc; 55 private ServiceContext serviceContext; 58 private ServiceDescription service; 59 60 private boolean finish = false; 61 62 public ServiceDispatchingTest() { 63 super(ServiceDispatchingTest.class.getName()); 64 } 65 66 public ServiceDispatchingTest(String testName) { 67 super(testName); 68 } 69 70 protected void setUp() throws Exception { 71 UtilServer.start(); 72 service = Utils.createSimpleService(serviceName, Echo.class.getName(), operationName); 73 UtilServer.deployService(service); 74 serviceContext = 75 UtilServer.getConfigurationContext().createServiceContext(service.getName()); 76 77 } 78 79 protected void tearDown() throws Exception { 80 UtilServer.unDeployService(serviceName); 81 UtilServer.stop(); 82 } 83 84 public void testDispatchWithURLOnly() throws Exception { 85 SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); 86 OMElement payload = TestingUtils.createDummyOMElement(); 87 org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(); 88 call.setTo( 89 new EndpointReference( 90 AddressingConstants.WSA_TO, 91 "http://127.0.0.1:5555/axis/services/EchoXMLService/echoOMElement")); 92 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false); 93 OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload); 94 TestingUtils.campareWithCreatedOMElement(result); 95 call.close(); 96 } 97 public void testDispatchWithURLAndSOAPAction() throws Exception { 98 SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); 99 OMNamespace omNs = fac.createOMNamespace("http://dummyURL", "my"); 100 OMElement payload = fac.createOMElement("echoOMElementRequest", omNs); 101 OMElement value = fac.createOMElement("myValue", omNs); 102 value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega")); 103 payload.addChild(value); 104 org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(); 105 call.setTo( 106 new EndpointReference( 107 AddressingConstants.WSA_TO, 108 "http://127.0.0.1:5555/axis/services/EchoXMLService/")); 109 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false); 110 call.setSoapAction("echoOMElement"); 111 OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload); 112 TestingUtils.campareWithCreatedOMElement(result); 113 call.close(); 114 } 115 116 public void testDispatchWithSOAPBody() throws Exception { 117 SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); 118 119 OMNamespace omNs = fac.createOMNamespace("http://127.0.0.1:5555/axis/services/EchoXMLService", "my"); 120 OMElement payload = fac.createOMElement("echoOMElement", omNs); 121 OMElement value = fac.createOMElement("myValue", omNs); 122 value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega")); 123 payload.addChild(value); 124 125 126 org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(); 127 call.setTo( 128 new EndpointReference( 129 AddressingConstants.WSA_TO, 130 "http://127.0.0.1:5555/axis/services/")); 131 call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false); 132 OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload); 133 TestingUtils.campareWithCreatedOMElement(result); 134 call.close(); 135 } 136 } 137 | Popular Tags |