ODE-716: Fixed soap header processing

Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/489e41be
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/489e41be
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/489e41be

Branch: refs/heads/ode-1.3.x
Commit: 489e41bebab27daca93a7a4caff256f8fe822573
Parents: da0c50d
Author: sathwik <[email protected]>
Authored: Wed Aug 30 12:31:52 2017 +0530
Committer: sathwik <[email protected]>
Committed: Wed Aug 30 12:31:52 2017 +0530

----------------------------------------------------------------------
 .../org/apache/ode/axis2/SoapHeader2Test.java   | 27 +++++--
 .../resources/TestSoapHeader3/HelloWorld.bpel   | 73 ++++++++++++++++++
 .../resources/TestSoapHeader3/HelloWorld.wsdl   | 79 ++++++++++++++++++++
 .../test/resources/TestSoapHeader3/deploy.xml   | 30 ++++++++
 .../resources/TestSoapHeader3/testRequest.soap  | 29 +++++++
 .../ode/axis2/util/SoapMessageConverter.java    |  5 +-
 .../ode/axis2/SoapMessageConverterTest.java     |  8 +-
 7 files changed, 238 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2-war/src/test/java/org/apache/ode/axis2/SoapHeader2Test.java
----------------------------------------------------------------------
diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/SoapHeader2Test.java 
b/axis2-war/src/test/java/org/apache/ode/axis2/SoapHeader2Test.java
index f746fff..0967701 100644
--- a/axis2-war/src/test/java/org/apache/ode/axis2/SoapHeader2Test.java
+++ b/axis2-war/src/test/java/org/apache/ode/axis2/SoapHeader2Test.java
@@ -23,25 +23,22 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.ode.axis2.Axis2TestBase;
 import org.apache.ode.axis2.JettyWrapper;
-import org.apache.ode.axis2.httpbinding.HttpBindingTest;
 import org.apache.ode.utils.DOMUtils;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
+import org.w3c.dom.Element;
 import org.mortbay.jetty.handler.ContextHandler;
 import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.Request;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
 import javax.servlet.ServletException;
-import java.util.concurrent.CountDownLatch;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 import java.io.IOException;
-import java.io.StringReader;
+
 
 /**
  * <p/>
@@ -112,11 +109,27 @@ public class SoapHeader2Test extends Axis2TestBase {
         try {
             String response = 
server.sendRequestFile("http://localhost:8888/processes/hello/hello/process/client";,
                     bundleName, "testRequest.soap");
-            if (log.isDebugEnabled()) log.debug(response);
+            log.debug(response);
             assertTrue("Soap headers missing!", 
response.contains("TestSoapHeader2 passed"));
         } finally {
             server.undeployProcess(bundleName);
         }
     }
 
+    @Test
+    public void testSoapHeaders3() throws Exception {
+        String bundleName = "TestSoapHeader3";
+        // deploy the required service
+        if (!server.isDeployed(bundleName)) server.deployProcess(bundleName);
+        try {
+            String response = 
server.sendRequestFile("http://localhost:8888/processes/hello_world_header_wsdl";,
+                    bundleName, "testRequest.soap");
+            log.debug(response);
+            assertTrue(response!=null);
+            Element resEle = DOMUtils.stringToDOM(response);
+            assertTrue(DOMUtils.findChildByName(resEle, new 
QName("http://www.example.org/cid","conversationId","cid";),true) != null);
+        } finally {
+            server.undeployProcess(bundleName);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.bpel
----------------------------------------------------------------------
diff --git a/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.bpel 
b/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.bpel
new file mode 100644
index 0000000..876afcd
--- /dev/null
+++ b/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.bpel
@@ -0,0 +1,73 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+<process name="HelloWorldHeaderWSDL"
+    targetNamespace="http://www.example.org/bpel/examples"; 
+    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+    xmlns:tns="http://www.example.org/bpel/examples";
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+    xmlns:intf="http://www.example.org/bpel/examples/wsdl";
+    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0" 
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable";>
+
+  <import location="HelloWorld.wsdl"
+     namespace="http://www.example.org/bpel/examples/wsdl";
+     importType="http://schemas.xmlsoap.org/wsdl/"; />
+
+   <partnerLinks>
+      <partnerLink name="helloPartnerLink" 
+         partnerLinkType="intf:HelloPartnerLinkType" 
+         myRole="me" />
+   </partnerLinks>
+    
+   <variables>
+     <variable name="myVar" messageType="intf:HelloMessage"/>
+     <variable name="mesgVar" type="xsd:string"/>
+     <variable name="conversationId" type="xsd:string"/>
+   </variables>
+
+   <sequence>
+       <receive
+          name="start"
+          partnerLink="helloPartnerLink"
+          portType="intf:HelloPortType"
+          operation="hello"
+          variable="myVar"
+          createInstance="yes"/>
+
+      <assign name="assignHelloMesg">
+          <copy>
+              <from variable="myVar" part="TestPart"/>
+              <to variable="mesgVar"/>
+          </copy>
+         <copy>
+               <from variable="myVar" part="conversationId"/>
+               <to variable="conversationId" />
+         </copy>
+          <copy>
+              <from>concat($mesgVar,' World', ' conversationId=', 
$conversationId)</from>
+              <to variable="myVar" part="TestPart"/>
+          </copy>
+      </assign>
+       <reply name="end"  
+              partnerLink="helloPartnerLink"
+              portType="intf:HelloPortType" 
+              operation="hello"
+              variable="myVar"/>
+   </sequence>
+</process>

http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.wsdl
----------------------------------------------------------------------
diff --git a/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.wsdl 
b/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.wsdl
new file mode 100644
index 0000000..8317ea0
--- /dev/null
+++ b/axis2-war/src/test/resources/TestSoapHeader3/HelloWorld.wsdl
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+<wsdl:definitions
+        targetNamespace="http://www.example.org/bpel/examples/wsdl";
+        xmlns="http://schemas.xmlsoap.org/wsdl/";
+        xmlns:tns="http://www.example.org/bpel/examples/wsdl";
+       xmlns:types="http://www.example.org/cid";
+        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
+        xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
+        xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype";>
+
+       <wsdl:types>
+               <xsd:schema targetNamespace="http://www.example.org/cid";>
+                       <xsd:element name="conversationId" type="xsd:string" />
+               </xsd:schema>
+       </wsdl:types>
+
+    <wsdl:message name="HelloMessage">
+        <wsdl:part name="TestPart" type="xsd:string"/>
+       <wsdl:part name="conversationId" element="types:conversationId" />
+    </wsdl:message>
+
+    <wsdl:portType name="HelloPortType">
+        <wsdl:operation name="hello">
+            <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+            <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+        <soap:binding style="rpc" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="hello">
+            <soap:operation soapAction="" style="rpc"/>
+            <wsdl:input>
+                <soap:body
+                        namespace="http://www.example.org/bpel/examples/wsdl";
+                        use="literal" parts="TestPart" />
+               <soap:header message="tns:HelloMessage"
+                         part="conversationId" use="literal"/>
+           </wsdl:input>
+            <wsdl:output>
+                <soap:body
+                        namespace="http://www.example.org/bpel/examples/wsdl";
+                        use="literal" parts="TestPart" />
+               <soap:header message="tns:HelloMessage"
+                         part="conversationId" use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloService">
+        <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+            <soap:address 
location="http://localhost:8080/ode/processes/hello_world_header_wsdl"/>
+        </wsdl:port>
+    </wsdl:service>
+
+    <plnk:partnerLinkType name="HelloPartnerLinkType">
+        <plnk:role name="me" portType="tns:HelloPortType"/>
+        <plnk:role name="you" portType="tns:HelloPortType"/>
+    </plnk:partnerLinkType>
+</wsdl:definitions>
+

http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2-war/src/test/resources/TestSoapHeader3/deploy.xml
----------------------------------------------------------------------
diff --git a/axis2-war/src/test/resources/TestSoapHeader3/deploy.xml 
b/axis2-war/src/test/resources/TestSoapHeader3/deploy.xml
new file mode 100644
index 0000000..399aad3
--- /dev/null
+++ b/axis2-war/src/test/resources/TestSoapHeader3/deploy.xml
@@ -0,0 +1,30 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03";
+       xmlns:bpl="http://www.example.org/bpel/examples"; 
+       xmlns:intf="http://www.example.org/bpel/examples/wsdl";>
+
+
+       <process name="bpl:HelloWorldHeaderWSDL">
+               <active>true</active>
+               <provide partnerLink="helloPartnerLink">
+                       <service name="intf:HelloService" port="HelloPort"/>
+               </provide>
+       </process>
+</deploy>

http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2-war/src/test/resources/TestSoapHeader3/testRequest.soap
----------------------------------------------------------------------
diff --git a/axis2-war/src/test/resources/TestSoapHeader3/testRequest.soap 
b/axis2-war/src/test/resources/TestSoapHeader3/testRequest.soap
new file mode 100644
index 0000000..8d26bd7
--- /dev/null
+++ b/axis2-war/src/test/resources/TestSoapHeader3/testRequest.soap
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:cid="http://www.example.org/cid"; 
xmlns:wsdl="http://www.example.org/bpel/examples/wsdl";>
+   <soapenv:Header>
+      <cid:conversationId>1</cid:conversationId>
+   </soapenv:Header>
+   <soapenv:Body>
+      <wsdl:hello>
+         <TestPart>hello</TestPart>
+      </wsdl:hello>
+   </soapenv:Body>
+</soapenv:Envelope>

http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
----------------------------------------------------------------------
diff --git 
a/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java 
b/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
index 49bc67d..f94b02b 100644
--- a/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
+++ b/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
@@ -259,7 +259,8 @@ public class SoapMessageConverter {
         for (Iterator<OMNode> i = omPart.getChildren(); i.hasNext();) {
             OMNode node = i.next();
             i.remove();
-            soaphdr.addChild(node);
+            if(node.getType() == OMNode.ELEMENT_NODE)
+                soaphdr.addChild(node);
         }
     }
 
@@ -466,7 +467,7 @@ public class SoapMessageConverter {
             Message hdrMsg = _def.getMessage(headerDef.getMessage());
             for (Object o : hdrMsg.getParts().values()) {
                 Part p = (Part) o;
-                if (p.getElementName().equals(elmtName)) return p.getName();
+                if (p.getElementName() != null && 
p.getElementName().equals(elmtName)) return p.getName();
             }
         }
         return elmtName.getLocalPart();

http://git-wip-us.apache.org/repos/asf/ode/blob/489e41be/axis2/src/test/java/org/apache/ode/axis2/SoapMessageConverterTest.java
----------------------------------------------------------------------
diff --git 
a/axis2/src/test/java/org/apache/ode/axis2/SoapMessageConverterTest.java 
b/axis2/src/test/java/org/apache/ode/axis2/SoapMessageConverterTest.java
index e6c6bca..543bfd0 100644
--- a/axis2/src/test/java/org/apache/ode/axis2/SoapMessageConverterTest.java
+++ b/axis2/src/test/java/org/apache/ode/axis2/SoapMessageConverterTest.java
@@ -29,10 +29,10 @@ import javax.xml.stream.XMLStreamReader;
 
 import junit.framework.TestCase;
 
-import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
+import org.apache.axiom.soap.SOAPModelBuilder;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.ode.axis2.util.SoapMessageConverter;
@@ -159,7 +159,7 @@ public class SoapMessageConverterTest extends TestCase {
 
         XMLStreamReader sr = 
XMLInputFactory.newInstance().createXMLStreamReader(
                 getClass().getResourceAsStream("/HelloWorldRequest.soap"));
-        StAXSOAPModelBuilder builder = 
OMXMLBuilderFactory.createStAXSOAPModelBuilder(new SOAP11Factory(), sr);
+        SOAPModelBuilder builder = 
OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMAbstractFactory.getMetaFactory(),
 sr);
         SOAPEnvelope se = builder.getSOAPEnvelope();
 
         Element msg = DOMUtils.stringToDOM("<message/>");

Reply via email to