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 ch...@apache.org on 2005/06/27 12:16:44 UTC

svn commit: r201964 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis/clientapi/ core/test/org/apache/axis/engine/ samples/test/org/apache/axis/engine/ samples/test/org/apache/axis/engine/util/

Author: chinthaka
Date: Mon Jun 27 03:16:42 2005
New Revision: 201964

URL: http://svn.apache.org/viewcvs?rev=201964&view=rev
Log:
- adding overall soap version to check whether engine is sending the SOAP message with the correct version.
- changed the call api to have SOAP URI in properly.

Added:
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/SOAPversionTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/util/
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/util/MyInOutMEPClient.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/MessageContextInjectionTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java?rev=201964&r1=201963&r2=201964&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Call.java Mon Jun 27 03:16:42 2005
@@ -37,7 +37,7 @@
 public class Call extends InOutMEPClient {
 
     private HashMap properties;
-    private static OperationDescription opreationTemplate;
+    protected static OperationDescription operationTemplate;
     /**
      * this is a convenience Class, here the Call will assume a Annoynmous Service.
      * @throws AxisFault
@@ -79,10 +79,10 @@
             serviceContext.getServiceConfig().getOperation(new QName(axisop));
          if (axisConfig == null) {
             axisConfig = new OperationDescription(new QName(axisop));
-            axisConfig.setRemainingPhasesInFlow(opreationTemplate.getRemainingPhasesInFlow());
-            axisConfig.setPhasesOutFlow(opreationTemplate.getPhasesOutFlow());
-            axisConfig.setPhasesInFaultFlow(opreationTemplate.getPhasesInFaultFlow());
-            axisConfig.setPhasesOutFaultFlow(opreationTemplate.getPhasesOutFaultFlow());
+            axisConfig.setRemainingPhasesInFlow(operationTemplate.getRemainingPhasesInFlow());
+            axisConfig.setPhasesOutFlow(operationTemplate.getPhasesOutFlow());
+            axisConfig.setPhasesInFaultFlow(operationTemplate.getPhasesInFaultFlow());
+            axisConfig.setPhasesOutFaultFlow(operationTemplate.getPhasesOutFaultFlow());
             serviceContext.getServiceConfig().addOperation(axisConfig);
         }
 
@@ -111,10 +111,10 @@
             serviceContext.getServiceConfig().getOperation(new QName(axisop));
         if (axisConfig == null) {
             axisConfig = new OperationDescription(new QName(axisop));
-            axisConfig.setRemainingPhasesInFlow(opreationTemplate.getRemainingPhasesInFlow());
-            axisConfig.setPhasesOutFlow(opreationTemplate.getPhasesOutFlow());
-            axisConfig.setPhasesInFaultFlow(opreationTemplate.getPhasesInFaultFlow());
-            axisConfig.setPhasesOutFaultFlow(opreationTemplate.getPhasesOutFaultFlow());
+            axisConfig.setRemainingPhasesInFlow(operationTemplate.getRemainingPhasesInFlow());
+            axisConfig.setPhasesOutFlow(operationTemplate.getPhasesOutFlow());
+            axisConfig.setPhasesInFaultFlow(operationTemplate.getPhasesInFaultFlow());
+            axisConfig.setPhasesOutFaultFlow(operationTemplate.getPhasesOutFaultFlow());
             serviceContext.getServiceConfig().addOperation(axisConfig);
         }
         MessageContext msgctx = prepareTheSystem(toSend);
@@ -127,7 +127,7 @@
      * @return ServiceContext that has a ConfigurationContext set in and has assumed values.
      * @throws AxisFault
      */
-    private static ServiceContext assumeServiceContext(String clinetHome) throws AxisFault {
+    protected static ServiceContext assumeServiceContext(String clinetHome) throws AxisFault {
         ConfigurationContext sysContext = null;
         if (ListenerManager.configurationContext == null) {
             ConfigurationContextFactory efac = new ConfigurationContextFactory();
@@ -139,8 +139,8 @@
         //create new service
         QName assumedServiceName = new QName("AnonnoymousService");
         ServiceDescription axisService = new ServiceDescription(assumedServiceName);
-        opreationTemplate = new OperationDescription(new QName("TemplateOperatin"));
-        axisService.addOperation(opreationTemplate);
+        operationTemplate = new OperationDescription(new QName("TemplateOperatin"));
+        axisService.addOperation(operationTemplate);
         sysContext.getAxisConfiguration().addService(axisService);
         ServiceContext service = sysContext.createServiceContext(assumedServiceName);
         return service;

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java?rev=201964&r1=201963&r2=201964&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MEPClient.java Mon Jun 27 03:16:42 2005
@@ -52,8 +52,7 @@
         }
 
         if (mep.equals(axisop.getMessageExchangePattern())) {
-            throw new AxisFault(
-                "This mepClient supports only "
+            throw new AxisFault("This mepClient supports only "
                     + mep
                     + " And the Axis Operations suppiled supports "
                     + axisop.getMessageExchangePattern());
@@ -84,8 +83,7 @@
         }
 
         if (transport != null) {
-            return serviceContext.getEngineContext().getAxisConfiguration().getTransportOut(
-                new QName(transport));
+            return serviceContext.getEngineContext().getAxisConfiguration().getTransportOut(new QName(transport));
 
         } else {
             throw new AxisFault("Cannot Infer transport from the URL");
@@ -93,12 +91,14 @@
 
     }
 
-    public SOAPEnvelope createDefaultSOAPEnvelope() {
+    public SOAPEnvelope createDefaultSOAPEnvelope() throws AxisFault{
         SOAPFactory fac = null;
         if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapVersionURI)) {
             fac = OMAbstractFactory.getSOAP12Factory();
-        } else {
+        } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapVersionURI)) {
             fac = OMAbstractFactory.getSOAP11Factory();
+        } else {
+             throw new AxisFault("Invalid SOAP URI. Axis2 only supports SOAP 1.1 and 1.2");
         }
         return fac.getDefaultEnvelope();
     }

Modified: webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/MessageContextInjectionTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/MessageContextInjectionTest.java?rev=201964&r1=201963&r2=201964&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/MessageContextInjectionTest.java (original)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/engine/MessageContextInjectionTest.java Mon Jun 27 03:16:42 2005
@@ -40,6 +40,7 @@
 import org.apache.axis.receivers.RawXMLINOnlyMessageRecevier;
 import org.apache.axis.soap.SOAPEnvelope;
 import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
 import org.apache.axis.transport.local.LocalTransportReceiver;
 import org.apache.axis.util.Utils;
 import org.apache.commons.logging.Log;
@@ -108,7 +109,7 @@
 
         sender.setTo(targetEPR);
         sender.setSenderTransport(Constants.TRANSPORT_LOCAL);
-
+        sender.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
         sender.send(operationName.getLocalPart(), payload);
         
     }

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java?rev=201964&r1=201963&r2=201964&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLTest.java Mon Jun 27 03:16:42 2005
@@ -154,4 +154,21 @@
         result.serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out)));
         call.close();
     }
+
+    public void testCorrectSOAPEnvelope() throws Exception {
+
+        OMElement payload = createEnvelope();
+
+        org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call();
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+
+        OMElement result =
+                (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+        result.serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out)));
+        call.close();
+    }
+
+
 }

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/SOAPversionTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/SOAPversionTest.java?rev=201964&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/SOAPversionTest.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/SOAPversionTest.java Mon Jun 27 03:16:42 2005
@@ -0,0 +1,123 @@
+package org.apache.axis.engine;
+
+import junit.framework.TestCase;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.integration.UtilServer;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.description.OperationDescription;
+import org.apache.axis.util.Utils;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.impl.llom.OMOutput;
+import org.apache.axis.Constants;
+import org.apache.axis.engine.util.MyInOutMEPClient;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+
+/*
+ * 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.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class SOAPversionTest 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;
+
+    protected void setUp() throws Exception {
+        UtilServer.start();
+        service =
+                Utils.createSimpleService(serviceName,
+        Echo.class.getName(),
+                        operationName);
+        UtilServer.deployService(service);
+        serviceContext =
+                UtilServer.getConfigurationContext().createServiceContext(service.getName());
+
+    }
+
+    public void testSOAP11() throws AxisFault {
+        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+        OMElement payload = createEnvelope();
+        MyInOutMEPClient inOutMEPClient = new MyInOutMEPClient();
+        inOutMEPClient.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        inOutMEPClient.setTo(targetEPR);
+        inOutMEPClient.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+
+        SOAPEnvelope result =
+                 inOutMEPClient.invokeBlockingWithEnvelopeOut(operationName.getLocalPart(), payload);
+        assertEquals("SOAP Version received is not compatible", SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, result.getNamespace().getName());
+        inOutMEPClient.close();
+    }
+
+    public void testSOAP12() throws AxisFault {
+        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+        OMElement payload = createEnvelope();
+        MyInOutMEPClient inOutMEPClient = new MyInOutMEPClient();
+        inOutMEPClient.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        inOutMEPClient.setTo(targetEPR);
+        inOutMEPClient.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+
+        SOAPEnvelope result =
+                 inOutMEPClient.invokeBlockingWithEnvelopeOut(operationName.getLocalPart(), payload);
+        assertEquals("SOAP Version received is not compatible", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, result.getNamespace().getName());
+
+
+        inOutMEPClient.close();
+    }
+
+    private OMElement createEnvelope() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+        OMElement method = fac.createOMElement("echoOMElement", omNs);
+        OMElement value = fac.createOMElement("myValue", omNs);
+        value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega"));
+        method.addChild(value);
+
+        return method;
+    }
+
+
+}

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/util/MyInOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/util/MyInOutMEPClient.java?rev=201964&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/util/MyInOutMEPClient.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/util/MyInOutMEPClient.java Mon Jun 27 03:16:42 2005
@@ -0,0 +1,61 @@
+package org.apache.axis.engine.util;
+
+import org.apache.axis.clientapi.InOutMEPClient;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.context.ServiceContext;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.OperationDescription;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.soap.SOAPEnvelope;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+
+/*
+ * 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.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class MyInOutMEPClient extends Call{
+
+    public MyInOutMEPClient() throws AxisFault {
+        super(assumeServiceContext(null));
+    }
+
+    public SOAPEnvelope invokeBlockingWithEnvelopeOut(String axisop, OMElement toSend) throws AxisFault {
+        OperationDescription axisConfig =
+            serviceContext.getServiceConfig().getOperation(new QName(axisop));
+         if (axisConfig == null) {
+            axisConfig = new OperationDescription(new QName(axisop));
+            axisConfig.setRemainingPhasesInFlow(operationTemplate.getRemainingPhasesInFlow());
+            axisConfig.setPhasesOutFlow(operationTemplate.getPhasesOutFlow());
+            axisConfig.setPhasesInFaultFlow(operationTemplate.getPhasesInFaultFlow());
+            axisConfig.setPhasesOutFaultFlow(operationTemplate.getPhasesOutFaultFlow());
+            serviceContext.getServiceConfig().addOperation(axisConfig);
+        }
+
+//        if (axisConfig == null) {
+//            axisConfig = new OperationDescription(new QName(axisop));
+//            serviceContext.getServiceConfig().addOperation(axisConfig);
+//        }
+        MessageContext msgctx = prepareTheSystem(toSend);
+
+        MessageContext responseContext = super.invokeBlocking(axisConfig, msgctx);
+        SOAPEnvelope envelope = responseContext.getEnvelope();
+        return envelope;
+    }
+}