servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r366459 - in /incubator/servicemix/trunk: pom.xml servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpSoapInOutBinding.java servicemix-components/src/test/java/org/apache/servicemix/components/http/HttpSoapTest.java
Date Fri, 06 Jan 2006 09:45:48 GMT
Author: gnodet
Date: Fri Jan  6 01:45:37 2006
New Revision: 366459

URL: http://svn.apache.org/viewcvs?rev=366459&view=rev
Log:
Fix namespaces for HttpSoapInOutBinding.
Upgrade xfire to latest snapshot.
Upgrade geronimo specs to 1.0

Modified:
    incubator/servicemix/trunk/pom.xml
    incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpSoapInOutBinding.java
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/http/HttpSoapTest.java

Modified: incubator/servicemix/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/pom.xml?rev=366459&r1=366458&r2=366459&view=diff
==============================================================================
--- incubator/servicemix/trunk/pom.xml (original)
+++ incubator/servicemix/trunk/pom.xml Fri Jan  6 01:45:37 2006
@@ -248,6 +248,11 @@
       <url>http://servicemix.org/m2-repo</url>
     </repository>
     <repository>
+      <id>apache-m2</id>
+      <name>Apache M2 Repository</name>
+      <url>http://cvs.apache.org/maven-snapshot-repository</url>
+    </repository>
+    <repository>
       <id>apache</id>
       <name>Apache Repository</name>
       <url>http://cvs.apache.org/repository</url>
@@ -690,62 +695,62 @@
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-activation</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-common</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-connector</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-core</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-deployment</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-j2ee</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-kernel</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-network</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-remoting</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-security</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-system</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo</groupId>
         <artifactId>geronimo-transaction</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.0</version>
       </dependency>
       <dependency>
         <groupId>geronimo-spec</groupId>
@@ -1175,12 +1180,12 @@
       <dependency>
         <groupId>servicemix</groupId>
         <artifactId>xfire-all</artifactId>
-        <version>1.0-20051222</version>
+        <version>1.0-20060106</version>
       </dependency>
       <dependency>
         <groupId>servicemix</groupId>
         <artifactId>xfire-jaxws</artifactId>
-        <version>1.0-20051222</version>
+        <version>1.0-20060106</version>
       </dependency>
       <dependency>
         <groupId>xml-apis</groupId>

Modified: incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpSoapInOutBinding.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpSoapInOutBinding.java?rev=366459&r1=366458&r2=366459&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpSoapInOutBinding.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpSoapInOutBinding.java
Fri Jan  6 01:45:37 2006
@@ -17,6 +17,8 @@
 
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
@@ -30,7 +32,9 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.XMLConstants;
 import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 
 import org.apache.servicemix.components.util.ComponentSupport;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
@@ -45,7 +49,13 @@
 import org.codehaus.xfire.service.binding.BeanInvoker;
 import org.codehaus.xfire.service.binding.ObjectServiceFactory;
 import org.codehaus.xfire.soap.SoapConstants;
+import org.codehaus.xfire.soap.handler.ReadHeadersHandler;
 import org.codehaus.xfire.transport.http.XFireServletController;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
 
 public class HttpSoapInOutBinding extends ComponentSupport implements
         HttpBinding {
@@ -100,7 +110,9 @@
             if (!result) {
                 throw new XFireFault("Error sending exchange", XFireFault.SENDER);
             }
-        } catch (JBIException e) {
+        } catch (XFireFault e) {
+            throw e;
+        } catch (Exception e) {
             throw new XFireFault(e);
         }
     }
@@ -149,10 +161,35 @@
 		}
     }
     
-    protected void populateExchange(MessageExchange exchange, Source src, MessageContext
ctx) throws JBIException {
+    protected void populateExchange(MessageExchange exchange, Source src, MessageContext
ctx) throws Exception {
         // TODO: Retrieve properties
         NormalizedMessage inMessage = exchange.createMessage();
-        inMessage.setContent(src);
+        // Add removed namespace declarations from the parents
+        Map namespaces = (Map) ctx.getProperty(ReadHeadersHandler.DECLARED_NAMESPACES);
+        Node node = transformer.toDOMNode(src);
+        Element element;
+        if (node instanceof Element) {
+        	element = (Element) node;
+        } else if (node instanceof Document) {
+        	element = ((Document) node).getDocumentElement();
+        } else {
+        	throw new UnsupportedOperationException("Unable to handle nodes of type " + node.getNodeType());
+        }
+        // Copy embedded namespaces from the envelope into the body root
+        for (Iterator it = namespaces.entrySet().iterator(); it.hasNext();) {
+        	Entry entry = (Entry) it.next();
+            if (element.getAttributes().getNamedItemNS(
+            		XMLConstants.XMLNS_ATTRIBUTE_NS_URI, 
+            		(String) entry.getKey()) == null) {
+            	element.setAttributeNS(
+            			XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+            			XMLConstants.XMLNS_ATTRIBUTE + ":" + (String) entry.getKey(),
+            			(String) entry.getValue());
+            }
+        }
+        // Set the source
+        inMessage.setContent(new DOMSource(element));
+        // Retrieve attachments
         Attachments attachments = (Attachments) ctx.getProperty(Attachments.ATTACHMENTS_KEY);
         if (attachments != null) {
             for (Iterator it = attachments.getParts(); it.hasNext();) {

Modified: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/http/HttpSoapTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/http/HttpSoapTest.java?rev=366459&r1=366458&r2=366459&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/http/HttpSoapTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/http/HttpSoapTest.java
Fri Jan  6 01:45:37 2006
@@ -42,6 +42,7 @@
 import org.apache.servicemix.jbi.messaging.InOnlyImpl;
 import org.apache.servicemix.jbi.util.DOMUtil;
 import org.apache.servicemix.jbi.util.FileUtil;
+import org.apache.servicemix.tck.ReceiverComponent;
 import org.apache.xpath.CachedXPathAPI;
 import org.springframework.core.io.ClassPathResource;
 import org.w3c.dom.Element;
@@ -185,6 +186,46 @@
         
 
         Node node = new SourceTransformer().toDOMNode(new SourceTransformer().toStreamSource(in.getContent()));
+        System.out.println(new SourceTransformer().toString(node));
+        
+        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
+        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "//*[local-name()
= 'userId']");
+        Element root = (Element) iterator.nextNode();
+        QName qname = DOMUtil.createQName(root, root.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance",
"type"));
+        assertEquals("http://www.w3.org/2001/XMLSchema", qname.getNamespaceURI());
+        assertEquals("string", qname.getLocalPart());
+    }
+    
+    public void testNamespaces() throws Exception {
+        ActivationSpec as = new ActivationSpec();
+        as.setId("receiver");
+        ReceiverComponent receiver = new ReceiverComponent();
+        as.setComponent(receiver);
+        as.setService(new QName("receiver"));
+        container.activateComponent(as);
+        
+        as = new ActivationSpec();
+        as.setId("http");
+        as.setDestinationService(new QName("receiver"));
+        HttpSoapConnector http = new HttpSoapConnector();
+        http.setDefaultInOut(false);
+        http.setPort(8100);
+        as.setComponent(http);
+        container.activateComponent(as);
+
+        URLConnection connection = new URL("http://localhost:8100").openConnection();
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+        OutputStream os = connection.getOutputStream();
+        // Post the request file.
+        InputStream fis = getClass().getResourceAsStream("soap-response.xml");
+        FileUtil.copyInputStream(fis, os);
+        connection.getInputStream();
+        
+        receiver.getMessageList().assertMessagesReceived(1);
+        NormalizedMessage msg = (NormalizedMessage) receiver.getMessageList().flushMessages().get(0);
+
+        Node node = new SourceTransformer().toDOMNode(new SourceTransformer().toStreamSource(msg.getContent()));
         System.out.println(new SourceTransformer().toString(node));
         
         CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();



Mime
View raw message