[jboss-svn-commits] JBL Code SVN: r36853 - labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Mar 18 17:26:05 EDT 2011


Author: dward
Date: 2011-03-18 17:26:05 -0400 (Fri, 18 Mar 2011)
New Revision: 36853

Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
Log:
Fix for JBESB-3584 "SOAPProxy needs to handle the document case where SOAPAction is not set"


Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java	2011-03-18 21:06:21 UTC (rev 36852)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java	2011-03-18 21:26:05 UTC (rev 36853)
@@ -45,10 +45,14 @@
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.MessagePayloadProxy;
+import org.jboss.ws.Constants;
 import org.jboss.ws.metadata.wsdl.WSDLBinding;
 import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
 import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
 import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLInterface;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
+import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput;
 import org.jboss.ws.metadata.wsdl.WSDLService;
 import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
 import org.xml.sax.Attributes;
@@ -165,6 +169,7 @@
 	private MessagePayloadProxy payloadProxy;
 	
 	private Map<String,QName> soapaction_to_binding = new HashMap<String,QName>();
+	private Map<QName,QName> element_to_operation = new HashMap<QName,QName>();
 	private Map<QName,QName> operation_to_binding = new HashMap<QName,QName>();
 	private Map<QName,SOAPProxyTransport> binding_to_transport = new HashMap<QName,SOAPProxyTransport>();
 	
@@ -190,6 +195,37 @@
 		}
 		for ( WSDLBinding wsdl_bind : wsdl_def.getBindings() )
 		{
+			WSDLInterface wsdl_iface = wsdl_bind.getInterface();
+			if (wsdl_iface != null)
+			{
+				for ( WSDLInterfaceOperation wsdl_iface_oper : wsdl_iface.getOperations() )
+				{
+					if ( Constants.URI_STYLE_DOCUMENT.equals(wsdl_iface_oper.getStyle()) )
+					{
+						WSDLInterfaceOperationInput[] wsdl_iface_oper_inputs = wsdl_iface_oper.getInputs();
+						if (wsdl_iface_oper_inputs.length != 1)
+						{
+							// length should only be 1 for document
+							continue;
+						}
+						WSDLInterfaceOperationInput wsdl_iface_oper_input = wsdl_iface_oper_inputs[0];
+						QName element = wsdl_iface_oper_input.getElement();
+						if ( element != null && !element_to_operation.containsKey(element) )
+						{
+							QName operation = wsdl_iface_oper.getName();
+							// no need for a duplicate mapping
+							if ( operation != null && !element.equals(operation) )
+							{
+								element_to_operation.put(element, operation);
+								if ( logger.isInfoEnabled() )
+								{
+									logger.info("mapped element [" + element + "] to operation [" + operation + "]");
+								}
+							}
+						}
+					}
+				}
+			}
 			for ( WSDLBindingOperation wsdl_bind_oper : wsdl_bind.getOperations() )
 			{
 				QName binding = wsdl_bind.getName();
@@ -298,35 +334,40 @@
 	
 	public Message process(Message message) throws ActionProcessingException
 	{
-		String soapaction = null;
 		HttpRequest request = HttpRequest.getRequest(message);
-		if (request != null)
-		{
-			soapaction = request.getHeaderValue("soapaction");
-		}
+		String soapaction = (request != null) ? request.getHeaderValue("soapaction") : null;
 		if (soapaction == null)
 		{
 			soapaction = (String)message.getProperties().getProperty("soapaction");
 		}
+		QName element = null;
+		QName operation = null;
 		QName binding = (soapaction != null) ? soapaction_to_binding.get(soapaction) : null;
-		QName operation = null;
 		if (binding == null)
 		{
 			if ( logger.isEnabledFor(Level.WARN) )
 			{
-				logger.warn("null binding for soapaction [" + soapaction + "]; parsing envelope to discover operation...");
+				logger.warn("null binding for soapaction [" + soapaction + "]; parsing envelope to find element or operation...");
 			}
-			operation = getOperation(message);
-			binding = (operation != null) ? operation_to_binding.get(operation) : null;
-			if ( binding == null  && logger.isEnabledFor(Level.ERROR) )
+			element = findElement(message);
+			operation = element;
+			if (element != null)
 			{
-				logger.error("null binding for operation [" + operation + "] in addition to soapaction [" + soapaction + "]");
+				if ( element_to_operation.containsKey(element) )
+				{
+					operation = element_to_operation.get(element);
+				}
+				binding = (operation != null) ? operation_to_binding.get(operation) : null;
 			}
 		}
+		if ( binding == null  && logger.isEnabledFor(Level.ERROR) )
+		{
+			logger.error("null binding for element [" + element + "] or operation [" + operation + "] in addition to soapaction [" + soapaction + "]");
+		}
 		SOAPProxyTransport transport = (binding != null) ? binding_to_transport.get(binding) : null;
 		if (transport == null)
 		{
-			throw new ActionProcessingException("null transport for soapaction [" + soapaction + "], operation [" + operation + "], binding [" + binding + "]");
+			throw new ActionProcessingException("null transport for soapaction [" + soapaction + "], element [" + element + "], operation [" + operation + "], binding [" + binding + "]");
 		}
 		if ( logger.isDebugEnabled() )
 		{
@@ -344,7 +385,7 @@
 	}
 	
 	// This is a best guess (and potentially expensive)!  See logger.warn(String) warning in process(Message) above.
-	private QName getOperation(Message message) throws ActionProcessingException
+	private QName findElement(Message message) throws ActionProcessingException
 	{
 		Object payload;
 		try
@@ -378,8 +419,8 @@
 		{
 			throw new ActionProcessingException( "unsupported payload type: " + payload.getClass().getName() );
 		}
-		QName operation = null;
-		ContentHandler ch = new OperationFinder();
+		QName element = null;
+		ContentHandler ch = new ElementFinder();
 		try
 		{
 			XMLReader xr = XMLReaderFactory.createXMLReader();
@@ -394,14 +435,14 @@
 		{
 			throw new ActionProcessingException(ioe);
 		}
-		catch (OperationFinder.OperationFound of)
+		catch (ElementFinder.ElementFound ef)
 		{
-			operation = of.operation;
+			element = ef.element;
 		}
-		return operation;
+		return element;
 	}
 	
-	private static class OperationFinder extends DefaultHandler
+	private static class ElementFinder extends DefaultHandler
 	{
 		
 		private boolean insideEnvelope = false;
@@ -421,19 +462,19 @@
 			else if (insideEnvelope && insideBody)
 			{
 				// stop parsing as soon as possible!
-				throw new OperationFound( new QName(uri, localName) );
+				throw new ElementFound( new QName(uri, localName) );
 			}
 		}
 		
 		@SuppressWarnings("serial")
-		private static class OperationFound extends RuntimeException
+		private static class ElementFound extends RuntimeException
 		{
 			
-			private QName operation;
+			private QName element;
 			
-			private OperationFound(QName operation)
+			private ElementFound(QName element)
 			{
-				this.operation = operation;
+				this.element = element;
 			}
 			
 		}



More information about the jboss-svn-commits mailing list