[jboss-svn-commits] JBL Code SVN: r36860 - labs/jbossesb/branches/JBESB_4_7_CP2_JBESB_3584/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
Mon Mar 21 16:03:36 EDT 2011
Author: tcunning
Date: 2011-03-21 16:03:35 -0400 (Mon, 21 Mar 2011)
New Revision: 36860
Modified:
labs/jbossesb/branches/JBESB_4_7_CP2_JBESB_3584/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
Log:
Merge over David Ward's fix for JBESB-3584 into a clean 4_7_CP2_ER4
+ JBESB-3584 branch.
Modified: labs/jbossesb/branches/JBESB_4_7_CP2_JBESB_3584/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP2_JBESB_3584/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2011-03-21 18:22:54 UTC (rev 36859)
+++ labs/jbossesb/branches/JBESB_4_7_CP2_JBESB_3584/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2011-03-21 20:03:35 UTC (rev 36860)
@@ -40,10 +40,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;
@@ -159,6 +163,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>();
@@ -183,6 +188,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();
@@ -262,35 +298,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() )
{
@@ -308,7 +349,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
@@ -342,8 +383,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();
@@ -358,14 +399,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;
@@ -385,19 +426,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