You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/01/17 03:26:44 UTC

svn commit: r369632 - in /incubator/servicemix/trunk/servicemix-soap: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/servicemix/ src/main/java/org/apache/servicemix/soap/ src/main/java/org/apache/...

Author: gnodet
Date: Mon Jan 16 18:26:38 2006
New Revision: 369632

URL: http://svn.apache.org/viewcvs?rev=369632&view=rev
Log:
Add soap support

Added:
    incubator/servicemix/trunk/servicemix-soap/   (with props)
    incubator/servicemix/trunk/servicemix-soap/pom.xml
    incubator/servicemix/trunk/servicemix-soap/src/
    incubator/servicemix/trunk/servicemix-soap/src/main/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Context.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Handler.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AbstractHandler.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AddressingInHandler.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/JBIMarshaler.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMarshaler.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMessage.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapWriter.java
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/package.html
    incubator/servicemix/trunk/servicemix-soap/src/test/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/
    incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapMessageMarshalerTest.java
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/log4j.properties
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/servicemix.jpg   (with props)
    incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/soap.xml

Propchange: incubator/servicemix/trunk/servicemix-soap/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 16 18:26:38 2006
@@ -0,0 +1,5 @@
+.settings
+target
+.project
+.wtpmodules
+.classpath

Added: incubator/servicemix/trunk/servicemix-soap/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/pom.xml?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/pom.xml (added)
+++ incubator/servicemix/trunk/servicemix-soap/pom.xml Mon Jan 16 18:26:38 2006
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 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.
+-->
+<!-- $Rev: 356052 $ $Date: 2005-12-11 14:41:20 -0800 (dim., 11 déc. 2005) $ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+    
+    <parent>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>servicemix</artifactId>
+        <version>3.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.servicemix</groupId>
+    <artifactId>servicemix-soap</artifactId>
+    <packaging>jar</packaging>
+    <name>ServiceMix :: SOAP</name>
+    <description>SOAP Stack</description>
+    
+    <dependencies>
+        
+        <dependency>
+	          <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+        </dependency>
+        <dependency>
+	          <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+	          <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-common</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Context.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Context.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Context.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Context.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class Context {
+
+	public static final String EXCHANGE_MEP = "org.apache.servicemix.ExchangeMep";
+	public static final String SOAP_MESSAGE = "org.apache.servicemix.SoapMessage";
+	public static final String INTERFACE = "org.apache.servicemix.Interface";
+	public static final String OPERATION = "org.apache.servicemix.Operation";
+	public static final String SERVICE = "org.apache.servicemix.Service";
+	public static final String ENDPOINT = "org.apache.servicemix.Endpoint";
+	
+	private Map properties;
+	
+	public Context() {
+		this.properties = new HashMap();
+	}
+	
+	public Object getProperty(String name) {
+		return properties.get(name);
+	}
+	
+	public void setProperty(String name, Object value) {
+		properties.put(name, value);
+	}
+	
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Handler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Handler.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Handler.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/Handler.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public interface Handler {
+
+	public void process(Context context) throws Exception;
+	
+	public void onComplete(Context context);
+	
+	public void onException(Context context, Exception e);
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapEndpoint.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,13 @@
+package org.apache.servicemix.soap;
+
+import java.net.URI;
+
+import org.apache.servicemix.common.Endpoint;
+
+public abstract class SoapEndpoint extends Endpoint {
+
+	public abstract URI getDefaultMep();
+	
+	
+	
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapFault.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap;
+
+import javax.xml.transform.Source;
+
+/**
+ * Represents a SOAP fault which occurred while processing the
+ * message.
+ *
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class SoapFault extends Exception {
+	
+	public static final String SENDER = "Sender";
+	public static final String RECEIVER = "Receiver";
+	
+    private String code;
+    private String subcode;
+    private String reason;
+    private String node;
+    private String role;
+    private Source details;
+
+    public SoapFault(Exception cause) {
+        super(cause);
+    }
+
+    public SoapFault(String code, String reason) {
+        this.code = code;
+        this.reason = reason;
+    }
+
+    public SoapFault(String code, String subcode, String reason) {
+        this.code = code;
+        this.subcode = subcode;
+        this.reason = reason;
+    }
+
+    public SoapFault(String code, String reason, String node, String role) {
+        this.code = code;
+        this.reason = reason;
+        this.node = node;
+        this.role = role;
+    }
+
+    public SoapFault(String code, String reason, String node, String role, Source details) {
+        this.code = code;
+        this.reason = reason;
+        this.node = node;
+        this.role = role;
+        this.details = details;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getSubcode() {
+        return subcode;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public String getNode() {
+        return node;
+    }
+
+    public String getRole() {
+        return role;
+    }
+
+	public Source getDetails() {
+		return details;
+	}
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.soap.marshalers.JBIMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.w3c.dom.Document;
+
+/**
+ * Helper class for working with soap endpoints
+ *
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class SoapHelper {
+
+    public static final URI IN_ONLY = URI.create("http://www.w3.org/2004/08/wsdl/in-only");
+    public static final URI IN_OUT = URI.create("http://www.w3.org/2004/08/wsdl/in-out");
+    public static final URI ROBUST_IN_ONLY = URI.create("http://www.w3.org/2004/08/wsdl/robust-in-only");
+    
+	private SoapEndpoint endpoint;
+    private List policies;
+    private JBIMarshaler jbiMarshaler;
+	
+	public SoapHelper() {
+		this.policies = new ArrayList();
+        this.jbiMarshaler = new JBIMarshaler();
+	}
+	
+	public SoapHelper(SoapEndpoint endpoint) {
+		this();
+		this.endpoint = endpoint;
+	}
+	
+    public void addPolicy(Handler policy) {
+    	policies.add(policy);
+    }
+
+	public Context createContext(SoapMessage message) {
+		Context context = new Context();
+		context.setProperty(Context.SOAP_MESSAGE, message);
+		context.setProperty(Context.OPERATION, message.getBodyName());
+		context.setProperty(Context.INTERFACE, endpoint.getInterfaceName());
+		context.setProperty(Context.SERVICE, endpoint.getService());
+		context.setProperty(Context.ENDPOINT, endpoint.getEndpoint());
+		return context;
+	}
+	
+	public MessageExchange createExchange(SoapMessage message) throws Exception {
+		Context context = createContext(message);
+		analyzeHeaders(context);
+		URI mep = findMep(context);
+		if (mep == null) {
+			mep = endpoint.getDefaultMep();
+		}
+        MessageExchange exchange = createExchange(mep);
+        exchange.setService((QName) context.getProperty(Context.SERVICE));
+        exchange.setInterfaceName((QName) context.getProperty(Context.INTERFACE));
+        exchange.setOperation((QName) context.getProperty(Context.OPERATION));
+        if (context.getProperty(Context.ENDPOINT) != null) {
+    		ComponentContext componentContext = endpoint.getServiceUnit().getComponent().getComponentContext();
+    		QName serviceName = (QName) context.getProperty(Context.SERVICE);
+    		String endpointName = (String) context.getProperty(Context.ENDPOINT);
+    		ServiceEndpoint se = componentContext.getEndpoint(serviceName, endpointName);
+    		if (se != null) {
+    			exchange.setEndpoint(se);
+    		}
+        }
+        NormalizedMessage inMessage = exchange.createMessage();
+        jbiMarshaler.toNMS(inMessage, message);
+        exchange.setMessage(inMessage, "in");
+        return exchange;
+	}
+	
+    public void analyzeHeaders(Context context) throws Exception {
+    	for (Iterator it = policies.iterator(); it.hasNext();) {
+    		Handler policy = (Handler) it.next();
+    		policy.process(context);
+    	}
+    }
+	
+    public MessageExchange createExchange(URI mep) throws MessagingException {
+        ComponentContext context = endpoint.getServiceUnit().getComponent().getComponentContext();
+        DeliveryChannel channel = context.getDeliveryChannel();
+        MessageExchangeFactory factory = channel.createExchangeFactory();
+        MessageExchange exchange = factory.createExchange(mep);
+        return exchange;
+    }
+    
+    public URI findMep(Context context) throws Exception {
+		QName interfaceName = (QName) context.getProperty(Context.INTERFACE);
+		QName serviceName = (QName) context.getProperty(Context.SERVICE);
+		QName operationName = (QName) context.getProperty(Context.OPERATION);
+		String endpointName = (String) context.getProperty(Context.ENDPOINT);
+		ComponentContext componentContext = endpoint.getServiceUnit().getComponent().getComponentContext();
+		// Find target endpoint
+		ServiceEndpoint se = null;
+		if (serviceName != null && endpointName != null) {
+			se = componentContext.getEndpoint(serviceName, endpointName);
+		}
+		if (se == null && interfaceName != null) {
+			ServiceEndpoint[] ses = componentContext.getEndpoints(interfaceName);
+			if (ses != null && ses.length > 0) {
+				se = ses[0];
+			}
+		}
+		// Find WSDL description
+        Definition definition = null;
+		if (se == null) {
+			// Get this endpoint definition
+			definition = endpoint.getDefinition();
+			if (definition == null && endpoint.getDescription() != null) {
+				// Eventually parse the definition
+	            WSDLFactory factory = WSDLFactory.newInstance();
+	            WSDLReader reader = factory.newWSDLReader();
+	            definition = reader.readWSDL(null, endpoint.getDescription());
+            	endpoint.setDefinition(definition);
+			}
+		} else {
+			// Find endpoint description from the component context
+			Document description = componentContext.getEndpointDescriptor(se);
+			if (description != null) {
+				// Parse WSDL
+				WSDLFactory factory = WSDLFactory.newInstance();
+				WSDLReader reader = factory.newWSDLReader();
+				definition = reader.readWSDL(null, description);
+			}
+		}
+		
+		// Find operation within description
+        URI mep = null;
+        if (interfaceName != null && operationName != null && definition != null) {
+        	PortType portType = definition.getPortType(interfaceName);
+        	if (portType != null) {
+	        	Operation oper = portType.getOperation(operationName.getLocalPart(), null, null);
+	        	if (oper != null) {
+	        		boolean output = oper.getOutput() != null && 
+	        		                 oper.getOutput().getMessage() != null &&
+	        		                 oper.getOutput().getMessage().getParts().size() > 0;
+	        		boolean faults = oper.getFaults().size() > 0;
+	        		if (output) {
+	        			mep = IN_OUT;
+	        		} else if (faults) {
+	        			mep = ROBUST_IN_ONLY;
+	        		} else {
+	        			mep = IN_ONLY;
+	        		}
+	        	}
+        	}
+        }
+        return mep;
+    }
+    
+	
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AbstractHandler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AbstractHandler.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AbstractHandler.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AbstractHandler.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.handlers;
+
+import org.apache.servicemix.soap.Context;
+import org.apache.servicemix.soap.Handler;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public abstract class AbstractHandler implements Handler {
+
+	public void onComplete(Context context) {
+	}
+
+	public void onException(Context context, Exception e) {
+	}
+
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AddressingInHandler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AddressingInHandler.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AddressingInHandler.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/handlers/AddressingInHandler.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.handlers;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.jbi.util.DOMUtil;
+import org.apache.servicemix.soap.Context;
+import org.apache.servicemix.soap.SoapFault;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class AddressingInHandler extends AbstractHandler {
+
+    public static final String WSA_NAMESPACE_200303 = "http://schemas.xmlsoap.org/ws/2003/03/addressing";
+    public static final String WSA_NAMESPACE_200408 = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+    public static final String WSA_NAMESPACE_200508 = "http://www.w3.org/2005/08/addressing";
+    
+    public static final String EL_ACTION = "Action";
+    public static final String EL_ADDRESS = "Address";
+    public static final String EL_FAULT_TO = "FaultTo";
+    public static final String EL_FROM = "From";
+    public static final String EL_MESSAGE_ID = "MessageID";
+    public static final String EL_METADATA = "Metadata";
+    public static final String EL_REFERENCE_PARAMETERS = "ReferenceParameters";
+    public static final String EL_RELATES_TO = "RelatesTo";
+    public static final String EL_REPLY_TO = "ReplyTo";
+    public static final String EL_TO = "To";
+    
+	public void process(Context context) throws Exception {
+		SoapMessage message = (SoapMessage) context.getProperty(Context.SOAP_MESSAGE);
+    	String action = null;
+    	String to = null;
+    	String nsUri = null;
+    	Map headers = message.getHeaders();
+    	if (headers != null) {
+	    	for (Iterator it = headers.keySet().iterator(); it.hasNext();) {
+	    		QName qname = (QName) it.next();
+	    		Object value = headers.get(qname);
+	    		if (WSA_NAMESPACE_200303.equals(qname.getNamespaceURI()) ||
+	    			WSA_NAMESPACE_200408.equals(qname.getNamespaceURI()) ||
+	    			WSA_NAMESPACE_200508.equals(qname.getNamespaceURI())) {
+	    			if (nsUri == null) {
+	    				nsUri = qname.getNamespaceURI();
+	    			} else if (!nsUri.equals(qname.getNamespaceURI())) {
+	    				throw new SoapFault(SoapFault.SENDER, "Inconsistent use of wsa namespaces");
+	    			}
+		    		if (qname.getLocalPart().equals(AddressingInHandler.EL_ACTION)) {
+		    			Element el = (Element) ((DocumentFragment) value).getFirstChild();
+		    			action = DOMUtil.getElementText(el);
+		        		String[] parts = split(action);
+		        		context.setProperty(Context.INTERFACE, new QName(parts[0], parts[1]));
+		        		context.setProperty(Context.OPERATION, new QName(parts[0], parts[2]));
+		    		} else if (qname.getLocalPart().equals(AddressingInHandler.EL_TO)) {
+		    			Element el = (Element) ((DocumentFragment) value).getFirstChild();
+		    			to = DOMUtil.getElementText(el);
+		        		String[] parts = split(to);
+		        		context.setProperty(Context.SERVICE, new QName(parts[0], parts[1]));
+		        		context.setProperty(Context.ENDPOINT, parts[2]);
+		    		} else {
+		    			// TODO: what ?
+		    		}
+	    		}
+	    	}
+    	}
+	}
+    
+    protected String[] split(String uri) {
+		char sep;
+		if (uri.indexOf('/') > 0) {
+			sep = '/';
+		} else {
+			sep = ':';
+		}
+		int idx1 = uri.lastIndexOf(sep);
+		int idx2 = uri.lastIndexOf(sep, idx1 - 1);
+		String epName = uri.substring(idx1 + 1);
+		String svcName = uri.substring(idx2 + 1, idx1);
+		String nsUri   = uri.substring(0, idx2);
+    	return new String[] { nsUri, svcName, epName };
+    }
+    
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/JBIMarshaler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/JBIMarshaler.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/JBIMarshaler.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/JBIMarshaler.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.marshalers;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.activation.DataHandler;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.JbiConstants;
+import org.w3c.dom.DocumentFragment;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class JBIMarshaler {
+
+	public void toNMS(NormalizedMessage normalizedMessage, SoapMessage soapMessage) throws Exception {
+    	if (soapMessage.hasHeaders()) {
+    		normalizedMessage.setProperty(JbiConstants.SOAP_HEADERS, soapMessage.getHeaders());
+    	}
+        if (soapMessage.hasAttachments()) {
+        	Map attachments = soapMessage.getAttachments();
+        	for (Iterator it = attachments.entrySet().iterator(); it.hasNext();) {
+        		Map.Entry entry = (Map.Entry) it.next();
+        		normalizedMessage.addAttachment((String) entry.getKey(), 
+        										(DataHandler) entry.getValue());
+        	}
+        }
+        normalizedMessage.setContent(soapMessage.getSource());
+	}
+	
+	public void fromNMS(SoapMessage soapMessage, NormalizedMessage normalizedMessage) {
+		if (normalizedMessage.getProperty(JbiConstants.SOAP_HEADERS) != null) {
+			Map headers = (Map) normalizedMessage.getProperty(JbiConstants.SOAP_HEADERS);
+        	for (Iterator it = headers.entrySet().iterator(); it.hasNext();) {
+        		Map.Entry entry = (Map.Entry) it.next();
+        		soapMessage.addHeader((QName) entry.getKey(), (DocumentFragment) entry.getValue());
+        	}
+		}
+		Set attachmentNames = normalizedMessage.getAttachmentNames();
+		for (Iterator it = attachmentNames.iterator(); it.hasNext();) {
+			String id = (String) it.next();
+			DataHandler handler = normalizedMessage.getAttachment(id);
+			soapMessage.addAttachment(id, handler);
+		}
+		soapMessage.setSource(normalizedMessage.getContent());
+	}
+
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMarshaler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMarshaler.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMarshaler.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMarshaler.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.marshalers;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.servicemix.jbi.jaxp.StAXSourceTransformer;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 359186 $
+ * @since 3.0 
+ */
+public class SoapMarshaler {
+
+	public static final String MULTIPART_CONTENT = "multipart/related";
+	public static final String SOAP_PART_ID = "soap-request";
+	public static final String SOAP_11_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+	public static final String SOAP_12_URI = "http://www.w3.org/2003/05/soap-envelope";
+	public static final String SOAP_PREFIX = "env";
+	public static final String ENVELOPE = "Envelope";
+	public static final String HEADER = "Header";
+	public static final String BODY = "Body";
+	public static final String FAULT = "Fault";
+
+	protected XMLInputFactory inputFactory;
+	protected XMLOutputFactory outputFactory;
+	protected StAXSourceTransformer  sourceTransformer;
+	protected boolean repairingNamespace;
+	protected String prefix = SOAP_PREFIX;
+	protected boolean soap = true;
+	protected String soapUri = SOAP_12_URI;
+
+	public SoapMarshaler() {
+	}
+
+	public SoapMarshaler(boolean soap) {
+		this.soap = soap;
+	}
+
+    public XMLInputFactory getInputFactory() {
+        if (inputFactory == null) {
+            inputFactory = XMLInputFactory.newInstance();
+            inputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
+        }
+        return inputFactory;
+    }
+
+    public XMLOutputFactory getOutputFactory() {
+        if (outputFactory == null) {
+            outputFactory = XMLOutputFactory.newInstance();
+            if (isRepairingNamespace()) {
+                outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, 
+                						  Boolean.valueOf(isRepairingNamespace()));
+            }
+        }
+        return outputFactory;
+    }
+    
+    public StAXSourceTransformer getSourceTransformer() {
+    	if (sourceTransformer == null) {
+    		sourceTransformer = new StAXSourceTransformer();
+    	}
+    	return sourceTransformer;
+    }
+
+    public boolean isRepairingNamespace() {
+        return repairingNamespace;
+    }
+
+    public void setRepairingNamespace(boolean repairingNamespace) {
+        this.repairingNamespace = repairingNamespace;
+    }
+    
+    public boolean isSoap() {
+    	return soap;
+    }
+    
+    public void setSoap(boolean soap) {
+    	this.soap = soap;
+    }
+    
+    public String getPrefix() {
+    	return prefix;
+    }
+    
+    public void setPrefix(String prefix) {
+    	this.prefix = prefix;
+    }
+    
+    public String getSoapUri() {
+    	return soapUri;
+    }
+    
+    public void setSoapUri(String soapUri) {
+    	this.soapUri = soapUri;
+    }
+    
+    public SoapReader createReader() {
+    	return new SoapReader(this);
+    }
+
+	public SoapWriter createWriter(SoapMessage message) {
+		return new SoapWriter(this, message);
+	}
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMessage.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMessage.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMessage.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapMessage.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.marshalers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.servicemix.soap.SoapFault;
+import org.w3c.dom.DocumentFragment;
+
+/**
+ * Simple DTO to hold attachments, soap headers and main xml source.
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 359186 $
+ * @since 3.0 
+ */
+public class SoapMessage {
+
+	private QName envelopeName;
+	private QName bodyName;
+	private Source source;
+	private Map attachments;
+	private Map headers;
+	private SoapFault fault;
+	
+	public Map getAttachments() {
+		return attachments;
+	}
+	public void setAttachments(Map attachments) {
+		this.attachments = attachments;
+	}
+	public void addAttachment(String name, DataHandler handler) {
+		if (this.attachments == null) {
+			this.attachments = new HashMap();
+		}
+		this.attachments.put(name, handler);
+	}
+	public boolean hasAttachments() {
+		return attachments != null && attachments.size() > 0;
+	}
+	
+	public Map getHeaders() {
+		return headers;
+	}
+	public void setHeaders(Map headers) {
+		this.headers = headers;
+	}
+	public void addHeader(QName name, DocumentFragment header) {
+		if (this.headers == null) {
+			this.headers = new HashMap();
+		}
+		this.headers.put(name, header);
+	}
+	public boolean hasHeaders() {
+		return headers != null && headers.size() > 0;
+	}
+	
+	public Source getSource() {
+		return source;
+	}
+	public void setSource(Source source) {
+		this.source = source;
+	}
+	
+	public QName getEnvelopeName() {
+		return envelopeName;
+	}
+	public void setEnvelopeName(QName envelopeName) {
+		this.envelopeName = envelopeName;
+	}
+	public QName getBodyName() {
+		return bodyName;
+	}
+	public void setBodyName(QName bodyName) {
+		this.bodyName = bodyName;
+	}
+	
+	public SoapFault getFault() {
+		return fault;
+	}
+	public void setFault(SoapFault fault) {
+		this.fault = fault;
+	}
+	
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.marshalers;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.mail.Session;
+import javax.mail.internet.ContentType;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.servicemix.jbi.jaxp.ExtendedXMLStreamReader;
+import org.apache.servicemix.jbi.jaxp.FragmentStreamReader;
+import org.apache.servicemix.jbi.jaxp.StaxSource;
+import org.apache.servicemix.soap.SoapFault;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class SoapReader {
+
+	private SoapMarshaler marshaler;
+
+	public SoapReader(SoapMarshaler marshaler) {
+		this.marshaler = marshaler;
+	}
+
+	public SoapMessage read(InputStream is, String contentType)
+			throws Exception {
+		if (contentType != null && contentType.toLowerCase().indexOf(SoapMarshaler.MULTIPART_CONTENT) != -1) {
+			Session session = Session.getDefaultInstance(new Properties());
+			MimeMessage mime = new MimeMessage(session, is);
+			mime.setHeader("Content-Type", contentType);
+			return read(mime);
+		} else {
+			return read(is);
+		}
+	}
+
+	public SoapMessage read(InputStream is) throws Exception {
+		if (marshaler.isSoap()) {
+			return readSoap(is);
+		} else {
+			SoapMessage message = new SoapMessage();
+			message.setSource(new StreamSource(is));
+			return message;
+		}
+	}
+
+	private SoapMessage readSoap(InputStream is) throws Exception {
+		SoapMessage message = new SoapMessage();
+		XMLStreamReader reader = marshaler.getInputFactory().createXMLStreamReader(is);
+		reader = new ExtendedXMLStreamReader(reader);
+		reader.nextTag();
+		// Check Envelope tag
+		if (!reader.getLocalName().equals(SoapMarshaler.ENVELOPE)) {
+			throw new SoapFault(SoapFault.SENDER, "Unrecognized element: "
+					+ reader.getName() + " at ["
+					+ reader.getLocation().getLineNumber() + ","
+					+ reader.getLocation().getColumnNumber()
+					+ "]. Expecting 'Envelope'.");
+		}
+		message.setEnvelopeName(reader.getName());
+		// Check soap 1.1 or 1.2
+		String soapUri = reader.getNamespaceURI();
+		if (!SoapMarshaler.SOAP_11_URI.equals(soapUri) && !SoapMarshaler.SOAP_12_URI.equals(soapUri)) {
+			throw new SoapFault(SoapFault.SENDER, "Unrecognized namespace: " + soapUri
+					+ " for element 'Envelope' at ["
+					+ reader.getLocation().getLineNumber() + ","
+					+ reader.getLocation().getColumnNumber()
+					+ "]. Expecting 'Envelope'.");
+		}
+		// Check Headers
+		reader.nextTag();
+		if (reader.getName().equals(new QName(soapUri, SoapMarshaler.HEADER))) {
+			parseHeaders(message, reader);
+			reader.nextTag();
+		}
+		// Check Body
+		if (!reader.getName().equals(new QName(soapUri, SoapMarshaler.BODY))) {
+			throw new SoapFault(SoapFault.SENDER, "Unrecognized element: "
+					+ reader.getName() + " at ["
+					+ reader.getLocation().getLineNumber() + ","
+					+ reader.getLocation().getColumnNumber()
+					+ "]. Expecting 'Body'.");
+		}
+		// Create Source for content
+		if (reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
+			message.setBodyName(reader.getName());
+			message.setSource(new StaxSource(new FragmentStreamReader(reader)));
+		}
+		return message;
+	}
+
+	private void parseHeaders(SoapMessage message, XMLStreamReader reader)
+			throws Exception {
+		while (reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
+			QName hn = reader.getName();
+			FragmentStreamReader rh = new FragmentStreamReader(reader);
+			Document doc = (Document) marshaler.getSourceTransformer().toDOMNode(
+					new StaxSource(rh));
+			DocumentFragment df = doc.createDocumentFragment();
+			df.appendChild(doc.getDocumentElement());
+			message.addHeader(hn, df);
+		}
+	}
+
+	public SoapMessage read(MimeMessage mime) throws Exception {
+		final Object content = mime.getContent();
+		if (content instanceof MimeMultipart) {
+			MimeMultipart multipart = (MimeMultipart) content;
+			ContentType type = new ContentType(mime.getContentType());
+			String contentId = type.getParameter("start");
+			if (contentId == null) {
+				contentId = ((MimeBodyPart) multipart.getBodyPart(0))
+						.getContentID();
+			}
+			// Get request
+			MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(contentId);
+			SoapMessage message = read(part.getInputStream());
+			for (int i = 0; i < multipart.getCount(); i++) {
+				part = (MimeBodyPart) multipart.getBodyPart(i);
+				String id = part.getContentID();
+				if (id != null && !id.equals(contentId)) {
+					if (id.startsWith("<")) {
+						id = id.substring(1, id.length() - 1);
+					}
+					message.addAttachment(id, part.getDataHandler());
+				}
+			}
+			return message;
+		} else {
+			throw new UnsupportedOperationException(
+					"Expected a javax.mail.internet.MimeMultipart object");
+		}
+	}
+
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapWriter.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapWriter.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapWriter.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapWriter.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.marshalers;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.activation.DataHandler;
+import javax.mail.Session;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+
+import org.apache.servicemix.jbi.jaxp.W3CDOMStreamReader;
+import org.apache.servicemix.jbi.jaxp.XMLStreamHelper;
+import org.apache.servicemix.jbi.util.ByteArrayDataSource;
+import org.apache.servicemix.soap.SoapFault;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ * @since 3.0
+ */
+public class SoapWriter {
+
+	public static final String SOAP_PART_ID = "soap-request";
+	
+	private SoapMessage message;
+	private String contentType;
+	private SoapMarshaler marshaler;
+	private MimeMultipart parts;
+	
+	public SoapWriter(SoapMarshaler marshaler, SoapMessage message) {
+		this.marshaler = marshaler;
+		this.message = message;
+		this.contentType = prepare();
+	}
+	
+	public String getContentType() {
+		return contentType;
+	}
+	
+	public void write(OutputStream out) throws Exception {
+		if (message.hasAttachments()) {
+			writeMultipartMessage(out);
+		} else {
+			writeSimpleMessage(out);
+		}
+	}
+	
+	private String prepare() {
+		if (message.hasAttachments()) {
+			parts = new MimeMultipart(
+					"related; type=\"text/xml\"; start=\"<" + SOAP_PART_ID
+							+ ">\"");
+			return parts.getContentType();
+		} else {
+			return "text/xml";
+		}
+	}
+
+	private void writeSimpleMessage(OutputStream out) throws Exception {
+		XMLStreamWriter writer = marshaler.getOutputFactory().createXMLStreamWriter(out);
+		writer.writeStartDocument();
+		if (marshaler.isSoap()) {
+			writeSoapEnvelope(writer);
+		} else {
+			if (message.hasHeaders()) {
+				throw new IllegalStateException("SOAP headers found on non-soap message");
+			}
+			writeContents(writer);
+		}
+		writer.writeEndDocument();
+		writer.flush();
+	}
+	
+	private void writeMultipartMessage(OutputStream out) throws Exception {
+		Session session = Session.getDefaultInstance(new Properties(), null);
+		MimeMessage mime = new MimeMessage(session);
+		// Add soap part
+		MimeBodyPart soapPart = new MimeBodyPart();
+		soapPart.setContentID("<" + SOAP_PART_ID + ">");
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		writeSimpleMessage(baos);
+		soapPart.setDataHandler(new DataHandler(new ByteArrayDataSource(baos.toByteArray(), "text/xml")));
+		parts.addBodyPart(soapPart);
+		// Add attachments
+		for (Iterator itr = message.getAttachments().entrySet().iterator(); itr
+				.hasNext();) {
+			Map.Entry entry = (Map.Entry) itr.next();
+			String id = (String) entry.getKey();
+			DataHandler dh = (DataHandler) entry.getValue();
+			MimeBodyPart part = new MimeBodyPart();
+			part.setDataHandler(dh);
+			part.setContentID("<" + id + ">");
+			parts.addBodyPart(part);
+		}
+		mime.setContent(parts);
+		mime.writeTo(out);
+	}
+	
+	private void writeSoapEnvelope(XMLStreamWriter writer) throws Exception {
+		QName envelope = getEnvelopeName();
+		String soapUri = envelope.getNamespaceURI();
+		String soapPrefix = envelope.getPrefix();
+		writer.setPrefix(soapPrefix, soapUri);
+        writer.writeStartElement(soapPrefix, SoapMarshaler.ENVELOPE, soapUri);
+        if (!marshaler.isRepairingNamespace()) {
+        	writer.writeNamespace(soapPrefix, soapUri);
+            //XMLStreamHelper.writeNamespacesExcludingPrefixAndNamespace(out, in, soapPrefix, soapUri);
+        }
+        // Write Header
+        if (message.getHeaders() != null && message.getHeaders().size() > 0) {
+            writer.writeStartElement(soapPrefix, SoapMarshaler.HEADER, soapUri);
+            for (Iterator it = message.getHeaders().values().iterator(); it.hasNext();) {
+            	DocumentFragment df = (DocumentFragment) it.next();
+            	Element e = (Element) df.getFirstChild();
+            	XMLStreamHelper.copy(new W3CDOMStreamReader(e), writer, marshaler.isRepairingNamespace());
+            }
+            writer.writeEndElement();
+        }
+        // Write Body
+        writer.writeStartElement(soapPrefix, SoapMarshaler.BODY, soapUri);
+        if (message.getFault() != null) {
+        	writeFault(writer);
+        } else if (message.getSource() != null) {
+        	writeContents(writer);
+        }  
+        writer.writeEndElement();
+        writer.writeEndElement();
+	}
+	
+	private void writeContents(XMLStreamWriter writer) throws Exception {
+        XMLStreamReader reader = marshaler.getSourceTransformer().toXMLStreamReader(message.getSource());
+        XMLStreamHelper.copy(reader, writer, marshaler.isRepairingNamespace());
+	}
+	
+	private void writeFault(XMLStreamWriter writer) throws Exception {
+		QName envelope = getEnvelopeName();
+		String soapUri = envelope.getNamespaceURI();
+        if (SoapMarshaler.SOAP_11_URI.equals(soapUri)) {
+        	writeSoap11Fault(writer);
+        } else {
+        	writeSoap12Fault(writer);
+        }
+	}
+
+	private void writeSoap11Fault(XMLStreamWriter writer) throws Exception {
+		// TODO
+		writeSoap12Fault(writer);
+	}
+	
+	private void writeSoap12Fault(XMLStreamWriter writer) throws Exception {
+		QName envelope = getEnvelopeName();
+		String soapUri = envelope.getNamespaceURI();
+		String soapPrefix = envelope.getPrefix();
+		writer.setPrefix(soapPrefix, soapUri);
+		SoapFault fault = message.getFault();
+		
+        writer.writeStartElement(soapPrefix, "Fault", soapUri);
+        String code = fault.getCode();
+        if (code != null) {
+        	writer.writeStartElement(soapPrefix, "Code", soapUri);
+        	writer.writeStartElement(soapPrefix, "Value", soapUri);
+        	writer.writeCharacters(soapPrefix + ":" + code);
+        	writer.writeEndElement();
+            String subcode = fault.getSubcode();
+            if (subcode != null) {
+            	writer.writeStartElement(soapPrefix, "Subcode", soapUri);
+            	writer.writeStartElement(soapPrefix, "Value", soapUri);
+            	writer.writeCharacters(subcode);
+            	writer.writeEndElement();
+                writer.writeEndElement();
+            }
+            writer.writeEndElement();
+        }
+        String reason = fault.getReason();
+        if (reason == null) {
+            reason = fault.getCause().toString();
+        }
+    	writer.writeStartElement(soapPrefix, "Reason", soapUri);
+    	writer.writeStartElement(soapPrefix, "Text", soapUri);
+    	writer.writeAttribute(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI, "lang", "en-US");
+    	writer.writeCharacters(reason);
+    	writer.writeEndElement();
+    	writer.writeEndElement();
+
+        String node = fault.getNode();
+        if (node != null) {
+        	writer.writeStartElement(soapPrefix, "Node", soapUri);
+        	writer.writeCharacters(node);
+        	writer.writeEndElement();
+        }
+
+        String role = fault.getRole();
+        if (role != null) {
+        	writer.writeStartElement(soapPrefix, "Role", soapUri);
+        	writer.writeCharacters(role);
+        	writer.writeEndElement();
+        }
+        
+        Source details = fault.getDetails();
+        if (details != null) {
+        	writer.writeStartElement(soapPrefix, "Details", soapUri);
+            XMLStreamReader reader = marshaler.getSourceTransformer().toXMLStreamReader(message.getSource());
+            XMLStreamHelper.copy(reader, writer, marshaler.isRepairingNamespace());
+            writer.writeEndElement();
+        }
+        
+        writer.writeEndElement();
+	}
+		
+	protected QName getEnvelopeName() {
+		QName name = message.getEnvelopeName();
+		if (name == null) {
+			name = new QName(marshaler.soapUri, SoapMarshaler.ENVELOPE, marshaler.prefix);
+		} else if (name.getPrefix() == null) {
+			name = new 	QName(name.getNamespaceURI(), name.getLocalPart(), marshaler.prefix); 
+		}
+		return name;
+	}
+
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/package.html
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/package.html?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/package.html (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/package.html Mon Jan 16 18:26:38 2006
@@ -0,0 +1,9 @@
+<html>
+<head>
+</head>
+<body>
+
+The core API and classes for the SOAP stack
+
+</body>
+</html>

Added: incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapMessageMarshalerTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapMessageMarshalerTest.java?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapMessageMarshalerTest.java (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapMessageMarshalerTest.java Mon Jan 16 18:26:38 2006
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2005-2006 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.servicemix.soap.marshalers;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URI;
+import java.util.Iterator;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.jaxp.BytesSource;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.util.DOMUtil;
+import org.apache.servicemix.soap.marshalers.SoapMarshaler;
+import org.apache.servicemix.soap.marshalers.SoapMessage;
+import org.apache.xpath.CachedXPathAPI;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.NodeIterator;
+
+/**
+ * 
+ * @author Guillaume Nodet
+ * @version $Revision: 1.5 $
+ */
+public class SoapMessageMarshalerTest extends TestCase {
+
+	private static final Log log = LogFactory.getLog(SoapMessageMarshalerTest.class);
+	
+	private SourceTransformer sourceTransformer = new SourceTransformer();
+	
+	public void testReadNonSoapMessage() throws Exception {
+		SoapMarshaler marshaler = new SoapMarshaler(false);
+		SoapMessage msg = marshaler.createReader().read(getClass().getResourceAsStream("soap.xml"));
+		assertNotNull(msg);
+		assertFalse(msg.hasAttachments());
+		assertFalse(msg.hasHeaders());
+		assertNotNull(msg.getSource());
+		Node node = sourceTransformer.toDOMNode(msg.getSource());
+		checkServiceNameNamespace(node);
+		checkUserIdNamespace(node);
+	}
+	
+	public void testWriteAndReadNonSoapMessage() throws Exception {
+		SoapMarshaler marshaler = new SoapMarshaler(false);
+		SoapMessage msg = new SoapMessage();
+		msg.setSource(new StreamSource(getClass().getResourceAsStream("soap.xml")));
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		marshaler.createWriter(msg).write(baos);
+		log.info(baos.toString());
+		
+		SoapMessage msg2 = marshaler.createReader().read(new ByteArrayInputStream(baos.toByteArray()));
+		assertNotNull(msg2);
+		assertFalse(msg2.hasAttachments());
+		assertFalse(msg2.hasHeaders());
+		assertNotNull(msg2.getSource());
+		Node node = sourceTransformer.toDOMNode(msg2.getSource());
+		checkServiceNameNamespace(node);
+		checkUserIdNamespace(node);
+	}
+	
+	public void testWriteAndReadNonSoapMessageWithAttachments() throws Exception {
+		SoapMarshaler marshaler = new SoapMarshaler(false);
+		SoapMessage msg = new SoapMessage();
+		msg.setSource(new StreamSource(getClass().getResourceAsStream("soap.xml")));
+		msg.addAttachment("servicemix.jpg", new DataHandler(new FileDataSource(new File(new URI(getClass().getResource("servicemix.jpg").toString())))));
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		SoapWriter writer = marshaler.createWriter(msg);
+		writer.write(baos);
+		log.info(baos.toString());
+		
+		SoapMessage msg2 = marshaler.createReader().read(new ByteArrayInputStream(baos.toByteArray()), writer.getContentType());
+		assertNotNull(msg2);
+		assertTrue(msg2.hasAttachments());
+		assertEquals(1, msg2.getAttachments().size());
+		DataHandler handler = (DataHandler) msg2.getAttachments().get(msg2.getAttachments().keySet().iterator().next());
+		assertNotNull(handler);
+		assertFalse(msg2.hasHeaders());
+		assertNotNull(msg2.getSource());
+		Node node = sourceTransformer.toDOMNode(msg2.getSource());
+		checkServiceNameNamespace(node);
+		checkUserIdNamespace(node);
+	}
+	
+	public void testWriteNonSoapMessageWithHeaders() throws Exception {
+		SoapMarshaler marshaler = new SoapMarshaler(false);
+		SoapMessage msg = new SoapMessage();
+		msg.addHeader(new QName("test"), null);
+		msg.setSource(null);
+		try {
+			marshaler.createWriter(msg).write(new ByteArrayOutputStream());
+			fail("Exception should have been thrown");
+		} catch (Exception e) {
+			// ok
+		}
+	}
+	
+	public void testSoapMessage() throws Exception {
+		SoapMarshaler marshaler = new SoapMarshaler(true);
+		
+		SoapMessage msg = marshaler.createReader().read(getClass().getResourceAsStream("soap.xml"));
+		assertNotNull(msg);
+		assertFalse(msg.hasAttachments());
+		assertTrue(msg.hasHeaders());
+		assertNotNull(msg.getSource());
+		
+		Iterator headers = msg.getHeaders().values().iterator();
+		assertTrue(headers.hasNext());
+		assertNotNull(headers.next());
+		assertTrue(headers.hasNext());
+        checkServiceNameNamespace((DocumentFragment) headers.next());
+		assertFalse(headers.hasNext());
+
+        Node node2 = sourceTransformer.toDOMNode(msg.getSource()); 
+        checkUserIdNamespace(node2);
+        
+        msg.setSource(new DOMSource(node2));
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        marshaler.createWriter(msg).write(baos);
+        Node node = sourceTransformer.toDOMNode(new BytesSource(baos.toByteArray()));
+        checkUserIdNamespace(node);
+	}
+	
+	public void testWriteAndReadSoapMessageWithAttachments() throws Exception {
+		SoapMarshaler marshaler = new SoapMarshaler(true);
+		SoapMessage msg = marshaler.createReader().read(getClass().getResourceAsStream("soap.xml"));
+		msg.addAttachment("servicemix.jpg", new DataHandler(new FileDataSource(new File(new URI(getClass().getResource("servicemix.jpg").toString())))));
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		SoapWriter writer = marshaler.createWriter(msg);
+		writer.write(baos);
+		log.info(baos.toString());
+		
+		SoapMessage msg2 = marshaler.createReader().read(new ByteArrayInputStream(baos.toByteArray()), writer.getContentType());
+		assertNotNull(msg2);
+		assertTrue(msg2.hasAttachments());
+		assertEquals(1, msg2.getAttachments().size());
+		DataHandler handler = (DataHandler) msg2.getAttachments().get(msg2.getAttachments().keySet().iterator().next());
+		assertNotNull(handler);
+		assertNotNull(msg2.getSource());
+        checkUserIdNamespace(sourceTransformer.toDOMNode(msg2.getSource()));
+		assertTrue(msg2.hasHeaders());
+		Iterator headers = msg2.getHeaders().values().iterator();
+		assertTrue(headers.hasNext());
+		assertNotNull(headers.next());
+		assertTrue(headers.hasNext());
+        checkServiceNameNamespace((DocumentFragment) headers.next());
+		assertFalse(headers.hasNext());
+	}
+	
+	protected void checkUserIdNamespace(Node node) throws Exception {
+        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()); 
+	}
+	
+	protected void checkServiceNameNamespace(Node node) throws Exception {
+        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); 
+        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "//*[local-name() = 'ServiceName']"); 
+        Element root = (Element) iterator.nextNode(); 
+        assertEquals(new QName("http://schemas.xmlsoap.org/ws/2003/03/addressing", "ServiceName"), 
+        		     new QName(root.getNamespaceURI(), root.getLocalName()));
+        QName qname = DOMUtil.createQName(root, root.getTextContent()); 
+        assertEquals(new QName("uri:test", "MyConsumerService"), qname); 
+	}
+	
+	
+}

Added: incubator/servicemix/trunk/servicemix-soap/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/test/resources/log4j.properties?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/resources/log4j.properties (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/resources/log4j.properties Mon Jan 16 18:26:38 2006
@@ -0,0 +1,21 @@
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true

Added: incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/servicemix.jpg
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/servicemix.jpg?rev=369632&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/servicemix.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/soap.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/soap.xml?rev=369632&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/soap.xml (added)
+++ incubator/servicemix/trunk/servicemix-soap/src/test/resources/org/apache/servicemix/soap/marshalers/soap.xml Mon Jan 16 18:26:38 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<e:Envelope xmlns:e="http://schemas.xmlsoap.org/soap/envelope/"
+  xmlns:wsa='http://schemas.xmlsoap.org/ws/2003/03/addressing'
+  xmlns:d="http://www.w3.org/2001/XMLSchema"
+  xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:wn0="http://systinet.com/xsd/SchemaTypes/"
+  xmlns:wn1="http://systinet.com/wsdl/com/cexp/coe/bob/ws/customer/"
+  xmlns:wn2="http://systinet.com/soap-jta/"
+  xmlns:wn3="http://systinet.com/wsdl/com/cexp/coe/bob/services/order/pojo/"
+  xmlns:test="uri:test">
+  <e:Header>
+    <wsa:To>http://test/MyConsumerService/myConsumer</wsa:To>
+    <wsa:ReplyTo>
+      <wsa:ServiceName>test:MyConsumerService</wsa:ServiceName>
+    </wsa:ReplyTo>
+  </e:Header>
+  <e:Body>
+    <wn1:getCustomerInfo>
+      <wn1:userId i:type="d:string">akayali</wn1:userId>
+    </wn1:getCustomerInfo>
+  </e:Body>
+</e:Envelope>