Author: heiko.braun(a)jboss.com
Date: 2009-11-05 16:03:41 -0500 (Thu, 05 Nov 2009)
New Revision: 238
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
Log:
Rely on inbound MessageContext
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2009-11-05
20:24:31 UTC (rev 237)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2009-11-05
21:03:41 UTC (rev 238)
@@ -77,7 +77,6 @@
protected Database _db;
protected ExecutorService _executorService;
protected CronScheduler _cronScheduler;
- //protected java.io.File _workRoot;
private java.util.List<IntegrationLayer> m_integrationLayers=new
java.util.Vector<IntegrationLayer>();
@@ -112,7 +111,10 @@
MyRoleMessageExchange odeMex = null;
Future responseFuture = null;
boolean wsInvocation = (message instanceof SOAPEnvelope);
- try {
+
+ try
+ {
+ // start TX
_txMgr.begin();
if (__log.isDebugEnabled()) __log.debug("Starting transaction.");
@@ -122,7 +124,9 @@
__log.debug("ODE routed to operation " + odeMex.getOperation() + "
from service " + service);
//odeMex.setProperty("isTwoWay",
Boolean.toString(msgContext.getAxisOperation() instanceof TwoChannelAxisOperation));
- if (odeMex.getOperation() != null) {
+ if (odeMex.getOperation() != null)
+ {
+
// Preparing message to send to ODE
Message odeRequest =
odeMex.createMessage(odeMex.getOperation().getInput().getMessage().getQName());
//_converter.parseSoapRequest(odeRequest, msgContext.getEnvelope(),
odeMex.getOperation());
@@ -130,16 +134,24 @@
// distinguish WS and ESB invocation
if(wsInvocation)
{
- // TODO: Use SOAPMessageAdapter here
- //SOAPMessageAdapter soapAdapter = new SOAPMessageAdapter(null,
odeMex.getServiceName(), odeMex.get)
-
odeRequest.setMessage(AbstractWebServiceEndpoint.getMessagePayload((SOAPEnvelope)message));
+ MessageContext inboundMessageContext = MessageContextAssoc.getInbound();
+ SOAPMessage soapMessage = inboundMessageContext.getMessage();
+ SOAPMessageAdapter soapAdapter =
+ new SOAPMessageAdapter(
+ inboundMessageContext.getWsdlDefinition(),
+ odeMex.getServiceName(),
+ inboundMessageContext.getPortName()
+ );
+ soapAdapter.parseSoapRequest(odeRequest, soapMessage, odeMex.getOperation());
+
+
//odeRequest.setMessage(AbstractWebServiceEndpoint.getMessagePayload((SOAPEnvelope)message));
}
else
{
wsInvocation = false;
odeRequest.setMessage(message);
}
-
+
// TODO: Might need to store session id/epr of caller?
//readHeader(msgContext, odeMex);
@@ -449,8 +461,8 @@
_executorService = Executors.newCachedThreadPool(threadFactory);
else
_executorService = Executors.newFixedThreadPool(_odeConfig.getThreadPoolMaxSize(),
threadFactory);
-
+
_bpelServer = new BpelServerImpl();
_scheduler = createScheduler();
_scheduler.setJobProcessor(_bpelServer);
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2009-11-05
20:24:31 UTC (rev 237)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2009-11-05
21:03:41 UTC (rev 238)
@@ -83,7 +83,7 @@
);
ref = endpointManager.createEndpoint(endpointMD, wsdlReference, classLoader);
-
+
}
catch (Throwable e)
{
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2009-11-05
20:24:31 UTC (rev 237)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2009-11-05
21:03:41 UTC (rev 238)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.utils.DOMUtils;
import org.jboss.soa.bpel.runtime.engine.BPELEngine;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -33,6 +32,9 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import javax.xml.ws.Provider;
@@ -49,58 +51,48 @@
{
protected final Log log = LogFactory.getLog(getClass());
- private Definition wsdlDefinition;
- private SOAPMessageAdapter soapMessageAdapter;
-
+ private Definition wsdlDefinition = null;
private boolean isInit;
-
- /* private void init()
+
+ private void init()
{
if(!isInit)
{
try
{
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- log.debug("Creating WebServiceEndpoint from " + getWsdlLocation());
- this.wsdlDefinition = wsdlReader.readWSDL( getWsdlLocation() );
- this.soapMessageAdapter = new SOAPMessageAdapter(
- wsdlDefinition,
- QName.valueOf(getServiceName()),
- getPortName()
- );
+ wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
}
- catch(Exception e)
+ catch (WSDLException e)
{
- throw new IllegalArgumentException("Failed to parse " +
getWsdlLocation());
+ throw new RuntimeException("Failed to parse WSDL", e);
}
-
isInit = true;
}
- } */
-
- public SOAPMessage invoke(SOAPMessage request)
+ }
+ public SOAPMessage invoke(SOAPMessage soapMessage)
{
log.debug("Invoking endpoint "+getEndpointId());
-
+ init();
+
try
{
- SOAPPart soapPart = request.getSOAPPart();
+ SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
Element messageElement = getMessagePayload(soapEnvelope);
// make sure namespaces are preserved
- DOMUtils.pancakeNamespaces(soapEnvelope);
+ //DOMUtils.pancakeNamespaces(soapEnvelope);
- // TODO:
https://jira.jboss.org/jira/browse/RIFTSAW-38
- // For now create a deep copy (performance hit)
-
- /*DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = builder.newDocument();
- Element clone = (Element)doc.importNode(messageElement, true); */
-
if(log.isDebugEnabled())
- log.debug( "ODE inbound message: \n"
+DOMWriter.printNode(messageElement, true) );
+ log.debug( "ODE inbound message: \n" +DOMWriter.printNode(soapEnvelope,
true) );
+ MessageContext context = MessageContextAssoc.createInbound();
+ context.setMessage(soapMessage);
+ context.setServiceName(QName.valueOf(getServiceName()));
+ context.setPortName(getPortName());
+ context.setWsdlDefinition(wsdlDefinition);
+
Element odeResponse = getEngine().invoke(
messageElement.getLocalName(),
QName.valueOf(getServiceName()),
@@ -110,17 +102,21 @@
if(!(odeResponse instanceof SOAPEnvelope))
throw new IllegalArgumentException("Expected SOAPEnvelope, got
"+odeResponse.getClass());
- if(log.isDebugEnabled())
- log.debug( "ODE outbound message: \n" +DOMWriter.printNode(odeResponse,
true) );
-
if(null==MessageContextAssoc.getOutbound())
throw new IllegalArgumentException("No outbound MessageContext");
- /* SOAPBody responseBody = soapResponse.getSOAPBody();
+ SOAPMessage responseMessage = MessageContextAssoc.getOutbound().getMessage();
+
+ if(log.isDebugEnabled())
+ log.debug( "ODE outbound message: \n" +
+ DOMWriter.printNode(responseMessage.getSOAPPart().getEnvelope(), true)
+ );
+
+ /* SOAPBody responseBody = soapResponse.getSOAPBody();
SOAPFactory soapFactory = SOAPFactory.newInstance();
SOAPElement responseElement = soapFactory.createElement(odeResponse);
responseBody.appendChild(responseElement);*/
- SOAPMessage responseMessage = MessageContextAssoc.getOutbound().getMessage();
+
return responseMessage;
}
catch (Exception e)
@@ -131,7 +127,7 @@
{
MessageContextAssoc.clearAll();
}
-
+
}
public static Element getMessagePayload(SOAPEnvelope soapEnvelope)
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java 2009-11-05
20:24:31 UTC (rev 237)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/MessageContext.java 2009-11-05
21:03:41 UTC (rev 238)
@@ -21,6 +21,8 @@
*/
package org.jboss.soa.bpel.runtime.ws;
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
/**
@@ -29,6 +31,9 @@
public class MessageContext
{
private SOAPMessage message;
+ private QName serviceName;
+ private String portName;
+ private Definition wsdlDefinition;
protected MessageContext()
{
@@ -43,4 +48,34 @@
{
return message;
}
+
+ public QName getServiceName()
+ {
+ return serviceName;
+ }
+
+ public void setServiceName(QName serviceName)
+ {
+ this.serviceName = serviceName;
+ }
+
+ public String getPortName()
+ {
+ return portName;
+ }
+
+ public void setPortName(String portName)
+ {
+ this.portName = portName;
+ }
+
+ public void setWsdlDefinition(Definition wsdlDefinition)
+ {
+ this.wsdlDefinition = wsdlDefinition;
+ }
+
+ public Definition getWsdlDefinition()
+ {
+ return wsdlDefinition;
+ }
}
Modified:
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
===================================================================
---
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2009-11-05
20:24:31 UTC (rev 237)
+++
branches/hbraun/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2009-11-05
21:03:41 UTC (rev 238)
@@ -232,19 +232,27 @@
if (bo == null)
throw new RuntimeException("Binding output not found on
"+serviceName+"/"+portName);
-
- javax.wsdl.extensions.soap.SOAPBody wsdlSOAPBody = getSOAPBody(bo);
- extractSoapBodyParts(odeMessage, soapMessage, wsdlSOAPBody,
odeOperation.getOutput().getMessage(), odeOperation.getName() + "Response");
-
+ extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bo),
odeOperation.getOutput().getMessage(), odeOperation.getName() + "Response");
extractSoapHeaderParts(odeMessage, soapMessage,
odeOperation.getOutput().getMessage());
}
public void parseSoapRequest(
org.apache.ode.bpel.iapi.Message odeMessage,
- SOAPEnvelope envelope,
- Operation op)
+ SOAPMessage soapMessage,
+ Operation op)
{
- throw new RuntimeException("Not implemented");
+
+ BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);
+
+ if (bop == null)
+ throw new RuntimeException("Binding operation not found
("+serviceName+"/"+portName);
+
+ BindingInput bi = bop.getBindingInput();
+ if (bi == null)
+ throw new RuntimeException("Binding inout not
found"+serviceName+"/"+portName);
+
+ extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bi),
op.getInput().getMessage(), op.getName());
+ extractSoapHeaderParts(odeMessage, soapMessage, op.getInput().getMessage());
}
public SOAPFault createSoapFault(Element message, QName faultName, Operation op) {