servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r405392 - /incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
Date Tue, 09 May 2006 11:39:19 GMT
Author: gnodet
Date: Tue May  9 04:39:17 2006
New Revision: 405392

URL: http://svn.apache.org/viewcvs?rev=405392&view=rev
Log:
SM-397: WSA:Action header should override default service/endpoint values from the http endpoint
definition

Modified:
    incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java

Modified: 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=405392&r1=405391&r2=405392&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
(original)
+++ incubator/servicemix/trunk/servicemix-soap/src/main/java/org/apache/servicemix/soap/SoapHelper.java
Tue May  9 04:39:17 2006
@@ -45,7 +45,7 @@
 
 /**
  * Helper class for working with soap endpoints
- *
+ * 
  * @author Guillaume Nodet
  * @version $Revision: 1.5 $
  * @since 3.0
@@ -53,55 +53,76 @@
 public class SoapHelper {
 
     private static final Log logger = LogFactory.getLog(SoapHelper.class);
-    
+
     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 SoapEndpoint endpoint;
     private List policies;
     private JBIMarshaler jbiMarshaler;
     private Map definitions;
-	
-	public SoapHelper(SoapEndpoint endpoint) {
+
+    public SoapHelper(SoapEndpoint endpoint) {
         this.policies = new ArrayList();
         this.definitions = new HashMap();
         this.jbiMarshaler = new JBIMarshaler();
-		this.endpoint = endpoint;
-	}
-	
+        this.endpoint = endpoint;
+    }
+
     public void addPolicy(Handler policy) {
-    	policies.add(policy);
+        policies.add(policy);
     }
 
-	public MessageExchange onReceive(Context context) throws Exception {
+    public MessageExchange onReceive(Context context) throws Exception {
         for (Iterator it = policies.iterator(); it.hasNext();) {
             Handler policy = (Handler) it.next();
             policy.onReceive(context);
         }
-		URI mep = findMep(context);
-		if (mep == null) {
-			mep = endpoint.getDefaultMep();
-		}
+        URI mep = findMep(context);
+        if (mep == null) {
+            mep = endpoint.getDefaultMep();
+        }
         MessageExchange exchange = createExchange(mep);
+        // If WS-A has not set informations, use the default ones
+        if (context.getProperty(Context.SERVICE) == null && context.getProperty(Context.INTERFACE)
== null) {
+            if (endpoint.getDefaultOperation() != null) {
+                context.setProperty(Context.OPERATION, endpoint.getDefaultOperation());
+            } else {
+                context.setProperty(Context.OPERATION, context.getInMessage().getBodyName());
+            }
+            // If no target endpoint / service / interface is defined
+            // we assume we use the same informations has defined on the
+            // external endpoint
+            if (endpoint.getTargetInterfaceName() == null && endpoint.getTargetService()
== null
+                            && endpoint.getTargetEndpoint() == null) {
+                context.setProperty(Context.INTERFACE, endpoint.getInterfaceName());
+                context.setProperty(Context.SERVICE, endpoint.getService());
+                context.setProperty(Context.ENDPOINT, endpoint.getEndpoint());
+            } else {
+                context.setProperty(Context.INTERFACE, endpoint.getTargetInterfaceName());
+                context.setProperty(Context.SERVICE, endpoint.getTargetService());
+                context.setProperty(Context.ENDPOINT, endpoint.getTargetEndpoint());
+            }
+        }
         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);
-    		}
+            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, context.getInMessage());
         exchange.setMessage(inMessage, "in");
         return exchange;
-	}
-    
+    }
+
     public SoapMessage onReply(Context context, NormalizedMessage outMsg) throws Exception
{
         SoapMessage out = new SoapMessage();
         if (context.getInMessage() != null) {
@@ -115,7 +136,7 @@
         }
         return out;
     }
-    
+
     public SoapMessage onFault(Context context, SoapFault fault) throws Exception {
         SoapMessage soapFault = new SoapMessage();
         soapFault.setFault(fault);
@@ -132,32 +153,13 @@
         }
         return soapFault;
     }
-    
+
     public Context createContext(SoapMessage message) {
         Context context = new Context();
         context.setInMessage(message);
-        if (endpoint.getDefaultOperation() != null) {
-            context.setProperty(Context.OPERATION, endpoint.getDefaultOperation());
-        } else {
-            context.setProperty(Context.OPERATION, message.getBodyName());
-        }
-        // If no target endpoint / service / interface is defined
-        // we assume we use the same informations has defined on the
-        // external endpoint
-        if (endpoint.getTargetInterfaceName() == null && 
-            endpoint.getTargetService() == null &&
-            endpoint.getTargetEndpoint() == null) {
-            context.setProperty(Context.INTERFACE, endpoint.getInterfaceName());
-            context.setProperty(Context.SERVICE, endpoint.getService());
-            context.setProperty(Context.ENDPOINT, endpoint.getEndpoint());
-        } else {
-            context.setProperty(Context.INTERFACE, endpoint.getTargetInterfaceName());
-            context.setProperty(Context.SERVICE, endpoint.getTargetService());
-            context.setProperty(Context.ENDPOINT, endpoint.getTargetEndpoint());
-        }
         return context;
     }
-    
+
     protected MessageExchange createExchange(URI mep) throws MessagingException {
         ComponentContext context = endpoint.getServiceUnit().getComponent().getComponentContext();
         DeliveryChannel channel = context.getDeliveryChannel();
@@ -165,31 +167,31 @@
         MessageExchange exchange = factory.createExchange(mep);
         return exchange;
     }
-    
+
     protected 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
+        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();
-		} else {
-			// Find endpoint description from the component context
+        if (se == null) {
+            // Get this endpoint definition
+            definition = endpoint.getDefinition();
+        } else {
+            // Find endpoint description from the component context
             String key = se.getServiceName() + se.getEndpointName();
             synchronized (definitions) {
                 definition = (Definition) definitions.get(key);
@@ -214,31 +216,29 @@
                     definitions.put(key, definition);
                 }
             }
-		}
-		
-		// Find operation within 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;
-	        		}
-	        	}
-        	}
+            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;
     }
-    
-	
+
 }



Mime
View raw message