servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r358572 - in /incubator/servicemix/trunk/servicemix-components: ./ src/main/java/org/servicemix/components/http/ src/main/java/org/servicemix/components/saaj/ src/test/java/org/servicemix/components/http/ src/test/resources/org/servicemix/c...
Date Thu, 22 Dec 2005 14:33:38 GMT
Author: gnodet
Date: Thu Dec 22 06:33:27 2005
New Revision: 358572

URL: http://svn.apache.org/viewcvs?rev=358572&view=rev
Log:
Add a test case for HttpSoap + Saaj invocation

Added:
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/servicemix/components/http/HttpSoapAndSaajTest.java
Modified:
    incubator/servicemix/trunk/servicemix-components/   (props changed)
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapClientMarshaler.java
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapInOutBinding.java
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/saaj/SaajMarshaler.java
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/http/soap-request.xml
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/xslt/example.xml

Propchange: incubator/servicemix/trunk/servicemix-components/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Dec 22 06:33:27 2005
@@ -0,0 +1,5 @@
+target
+activemq-data
+rootDir
+.classpath
+.project

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapClientMarshaler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapClientMarshaler.java?rev=358572&r1=358571&r2=358572&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapClientMarshaler.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapClientMarshaler.java
Thu Dec 22 06:33:27 2005
@@ -44,9 +44,9 @@
         String response = method.getResponseBodyAsString();
         Node node = sourceTransformer.toDOMNode(new StringSource(response));
         CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
-        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "/*/*[local-name()='Body']");
+        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "/*/*[local-name()='Body']/*");
         Node root = iterator.nextNode();
-        normalizedMessage.setContent(new DOMSource(root.getFirstChild()));
+        normalizedMessage.setContent(new DOMSource(root));
     }
 
     public void fromNMS(PostMethod method, MessageExchange exchange, NormalizedMessage normalizedMessage)
throws Exception {

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapInOutBinding.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapInOutBinding.java?rev=358572&r1=358571&r2=358572&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapInOutBinding.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/http/HttpSoapInOutBinding.java
Thu Dec 22 06:33:27 2005
@@ -55,6 +55,7 @@
     protected XFireServletController controller;
     protected Service service;
     protected boolean defaultInOut = true;
+    protected String soapAction = "\"\"";
 
     public HttpSoapInOutBinding() {
     }
@@ -87,7 +88,9 @@
             throw new XFireFault("Invalid source.", XFireFault.SENDER);
         }
         try {
-            XFireServletController.getResponse().setHeader("SOAPAction", "\"\"");
+        	if (soapAction != null) {
+        		XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
+        	}
             DeliveryChannel channel = getDeliveryChannel();
             MessageExchangeFactory factory = channel.createExchangeFactory();
             InOnly exchange = factory.createInOnlyExchange();
@@ -106,7 +109,9 @@
             throw new XFireFault("Invalid source.", XFireFault.SENDER);
         }
         try {
-            XFireServletController.getResponse().setHeader("SOAPAction", "");
+        	if (soapAction != null) {
+        		XFireServletController.getResponse().setHeader("SOAPAction", soapAction);
+        	}
             DeliveryChannel channel = getDeliveryChannel();
             MessageExchangeFactory factory = channel.createExchangeFactory();
             InOut exchange = factory.createInOutExchange();
@@ -198,5 +203,13 @@
     public void setDefaultInOut(boolean defaultInOut) {
         this.defaultInOut = defaultInOut;
     }
+
+	public String getSoapAction() {
+		return soapAction;
+	}
+
+	public void setSoapAction(String soapAction) {
+		this.soapAction = soapAction;
+	}
 
 }

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/saaj/SaajMarshaler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/saaj/SaajMarshaler.java?rev=358572&r1=358571&r2=358572&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/saaj/SaajMarshaler.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/servicemix/components/saaj/SaajMarshaler.java
Thu Dec 22 06:33:27 2005
@@ -54,7 +54,16 @@
     private MessageFactory messageFactory;
 
     public void toNMS(NormalizedMessage normalizedMessage, SOAPMessage soapMessage) throws
MessagingException, SOAPException {
-        addNmsProperties(normalizedMessage, soapMessage);
+
+        if (log.isDebugEnabled()) {
+        	try {
+	            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+	            soapMessage.writeTo(buffer);
+	            log.debug(new String(buffer.toByteArray()));
+        	} catch (Exception e) { }
+        }
+        
+    	addNmsProperties(normalizedMessage, soapMessage);
 
         SOAPPart soapPart = soapMessage.getSOAPPart();
         SOAPBody soapBody = soapPart.getEnvelope().getBody();
@@ -68,6 +77,12 @@
         			elem.setAttributeNS(att.getNamespaceURI(), att.getName(), att.getValue());
         		}
         	}
+        }
+        
+        if (log.isDebugEnabled()) {
+        	try {
+        		log.debug(transformer.toString(elem));
+        	} catch (Exception e) { }
         }
         
         normalizedMessage.setContent(new DOMSource(elem));

Added: incubator/servicemix/trunk/servicemix-components/src/test/java/org/servicemix/components/http/HttpSoapAndSaajTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/java/org/servicemix/components/http/HttpSoapAndSaajTest.java?rev=358572&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/servicemix/components/http/HttpSoapAndSaajTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/servicemix/components/http/HttpSoapAndSaajTest.java
Thu Dec 22 06:33:27 2005
@@ -0,0 +1,92 @@
+/**
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.components.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.messaging.URLEndpoint;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.servicemix.components.saaj.SaajBinding;
+import org.servicemix.components.util.EchoComponent;
+import org.servicemix.jbi.container.ActivationSpec;
+import org.servicemix.jbi.container.JBIContainer;
+import org.servicemix.jbi.jaxp.SourceTransformer;
+import org.servicemix.jbi.jaxp.StringSource;
+import org.servicemix.jbi.util.FileUtil;
+
+public class HttpSoapAndSaajTest extends TestCase {
+    
+    private static final int PORT = 7012;
+
+    protected JBIContainer container;
+    
+    protected void setUp() throws Exception {
+        container = new JBIContainer();
+        container.setMonitorInstallationDirectory(false);
+        container.setUseMBeanServer(false);
+        container.setCreateMBeanServer(false);
+        container.init();
+        container.start();
+    }
+    
+    protected void tearDown() throws Exception {
+        if (container != null) {
+            container.shutDown();
+        }
+    }
+    
+    public void testInOut() throws Exception {
+        ActivationSpec as = new ActivationSpec();
+        as.setId("saaj");
+        SaajBinding saaj = new SaajBinding();
+        saaj.setSoapEndpoint(new URLEndpoint("http://64.124.140.30/soap")); 
+        as.setComponent(saaj);
+        as.setService(new QName("saaj"));
+        container.activateComponent(as);
+        
+        as = new ActivationSpec();
+        as.setId("xfireBinding");
+        as.setComponent(new HttpSoapConnector(null, PORT, true));
+        as.setDestinationService(new QName("saaj"));
+        container.activateComponent(as);
+
+        URLConnection connection = new URL("http://localhost:" + PORT).openConnection();
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        OutputStream os = connection.getOutputStream();
+        // Post the request file.
+        InputStream fis = getClass().getResourceAsStream("soap-request.xml");
+        FileUtil.copyInputStream(fis, os);
+        // Read the response.
+        InputStream is = connection.getInputStream();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        FileUtil.copyInputStream(is, baos);
+        System.out.println(baos.toString());
+        
+        // Check xml validity
+        new SourceTransformer().toDOMNode(new StringSource(baos.toString()));
+    }
+
+}

Modified: incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/http/soap-request.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/http/soap-request.xml?rev=358572&r1=358571&r2=358572&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/http/soap-request.xml
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/http/soap-request.xml
Thu Dec 22 06:33:27 2005
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
 	<env:Body>
+	    <!-- Comment -->
 		<ns1:getQuote xmlns:ns1="urn:xmethods-delayed-quotes"
 			xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"
 			se:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

Modified: incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/xslt/example.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/xslt/example.xml?rev=358572&r1=358571&r2=358572&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/xslt/example.xml
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/servicemix/components/xslt/example.xml
Thu Dec 22 06:33:27 2005
@@ -99,7 +99,7 @@
         </bean></sm:component>
       </sm:activationSpec>
 
-      <sm:activationSpec componentName="jmsTrace" service="foo:trace">
+      <sm:activationSpec componentName="trace" service="foo:trace">
         <sm:component><bean class="org.servicemix.components.util.TraceComponent"/></sm:component>
       </sm:activationSpec>
       <!-- END SNIPPET: log -->



Mime
View raw message