You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by he...@apache.org on 2005/07/04 12:48:41 UTC
svn commit: r209056 - in /webservices/axis/trunk/java/modules:
core/src/org/apache/axis2/description/ core/src/org/apache/axis2/engine/
core/src/org/apache/axis2/transport/http/
samples/test/org/apache/axis2/engine/
Author: hemapani
Date: Mon Jul 4 03:48:38 2005
New Revision: 209056
URL: http://svn.apache.org/viewcvs?rev=209056&view=rev
Log:
add the test case for dispatching and fix the soap action based dispatching
Added:
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/ServiceDispatchingTest.java
Modified:
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java?rev=209056&r1=209055&r2=209056&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java Mon Jul 4 03:48:38 2005
@@ -153,8 +153,10 @@
* @return
*/
public OperationDescription getOperation(QName operationName) {
-
- return (OperationDescription) this.getServiceInterface().getAllOperations().get(operationName.getLocalPart());
+ String opStr = operationName.getLocalPart();
+
+ HashMap allOperations = this.getServiceInterface().getAllOperations();
+ return (OperationDescription) allOperations.get(opStr);
}
/*
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java?rev=209056&r1=209055&r2=209056&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java Mon Jul 4 03:48:38 2005
@@ -44,6 +44,9 @@
String action = (String) messageContext.getSoapAction();
if (action != null) {
OperationDescription op = service.getOperationBySOAPAction(action);
+ if(op == null){
+ op = service.getOperation(new QName(action));
+ }
return op;
}
return null;
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java?rev=209056&r1=209055&r2=209056&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java Mon Jul 4 03:48:38 2005
@@ -50,9 +50,14 @@
int contentLength)
throws AxisFault {
try {
- Object soapAction = msgContext.getWSAAction();
- String soapActionString =
- soapAction == null ? "" : soapAction.toString();
+
+ String soapActionString = msgContext.getSoapAction();
+ if(soapActionString == null || soapActionString.length() == 0){
+ soapActionString = msgContext.getWSAAction();
+ }
+ if(soapActionString == null){
+ soapActionString = "";
+ }
boolean doMTOM = msgContext.isDoingMTOM();
StringBuffer buf = new StringBuffer();
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=209056&r1=209055&r2=209056&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Mon Jul 4 03:48:38 2005
@@ -53,6 +53,9 @@
String soapAction, String requestURI,
ConfigurationContext configurationContext) throws AxisFault {
try {
+ if(soapAction != null && soapAction.startsWith("\"") && soapAction.endsWith("\"")){
+ soapAction = soapAction.substring(1,soapAction.length() -1);
+ }
msgContext.setWSAAction(soapAction);
msgContext.setSoapAction(soapAction);
msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO,
@@ -111,6 +114,9 @@
String soapAction, String requestURI,
ConfigurationContext configurationContext, Map requestParameters)
throws AxisFault {
+ if(soapAction != null && soapAction.startsWith("\"") && soapAction.endsWith("\"")){
+ soapAction = soapAction.substring(1,soapAction.length() -1);
+ }
msgContext.setWSAAction(soapAction);
msgContext.setSoapAction(soapAction);
msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO,
Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/ServiceDispatchingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/ServiceDispatchingTest.java?rev=209056&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/ServiceDispatchingTest.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/engine/ServiceDispatchingTest.java Mon Jul 4 03:48:38 2005
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.engine;
+
+//todo
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.integration.TestingUtils;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ServiceDispatchingTest extends TestCase {
+ private EndpointReference targetEPR =
+ new EndpointReference(
+ AddressingConstants.WSA_TO,
+ "http://127.0.0.1:"
+ + (UtilServer.TESTING_PORT)
+ + "/axis/services/EchoXMLService/echoOMElement");
+ private Log log = LogFactory.getLog(getClass());
+ private QName serviceName = new QName("EchoXMLService");
+ private QName operationName = new QName("echoOMElement");
+ private QName transportName = new QName("http://localhost/my", "NullTransport");
+
+ private AxisConfiguration engineRegistry;
+ private MessageContext mc;
+ //private Thread thisThread;
+ // private SimpleHTTPServer sas;
+ private ServiceContext serviceContext;
+ private ServiceDescription service;
+
+ private boolean finish = false;
+
+ public ServiceDispatchingTest() {
+ super(ServiceDispatchingTest.class.getName());
+ }
+
+ public ServiceDispatchingTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ UtilServer.start();
+ service = Utils.createSimpleService(serviceName, Echo.class.getName(), operationName);
+ UtilServer.deployService(service);
+ serviceContext =
+ UtilServer.getConfigurationContext().createServiceContext(service.getName());
+
+ }
+
+ protected void tearDown() throws Exception {
+ UtilServer.unDeployService(serviceName);
+ UtilServer.stop();
+ }
+
+ public void testDispatchWithURLOnly() throws Exception {
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+ OMElement payload = TestingUtils.createDummyOMElement();
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call();
+ call.setTo(
+ new EndpointReference(
+ AddressingConstants.WSA_TO,
+ "http://127.0.0.1:5555/axis/services/EchoXMLService/echoOMElement"));
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+ OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+ TestingUtils.campareWithCreatedOMElement(result);
+ call.close();
+ }
+ public void testDispatchWithURLAndSOAPAction() throws Exception {
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+ OMNamespace omNs = fac.createOMNamespace("http://dummyURL", "my");
+ OMElement payload = fac.createOMElement("echoOMElementRequest", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega"));
+ payload.addChild(value);
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call();
+ call.setTo(
+ new EndpointReference(
+ AddressingConstants.WSA_TO,
+ "http://127.0.0.1:5555/axis/services/EchoXMLService/"));
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+ call.setSoapAction("echoOMElement");
+ OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+ TestingUtils.campareWithCreatedOMElement(result);
+ call.close();
+ }
+
+ public void testDispatchWithSOAPBody() throws Exception {
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+ OMNamespace omNs = fac.createOMNamespace("http://127.0.0.1:5555/axis/services/EchoXMLService", "my");
+ OMElement payload = fac.createOMElement("echoOMElement", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega"));
+ payload.addChild(value);
+
+
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call();
+ call.setTo(
+ new EndpointReference(
+ AddressingConstants.WSA_TO,
+ "http://127.0.0.1:5555/axis/services/"));
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+ OMElement result = (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+ TestingUtils.campareWithCreatedOMElement(result);
+ call.close();
+ }
+}