riftsaw SVN: r507 - trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws.
by riftsaw-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2010-02-24 08:39:09 -0500 (Wed, 24 Feb 2010)
New Revision: 507
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java
Log:
* RIFTSAW-163: add header from soap payload.
Modified: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java 2010-02-23 22:03:13 UTC (rev 506)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java 2010-02-24 13:39:09 UTC (rev 507)
@@ -21,13 +21,22 @@
*/
package org.jboss.soa.bpel.runtime.ws;
+import java.io.ByteArrayOutputStream;
import java.lang.reflect.Method;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
+ * @author Jeff Yu <cyu(a)redhat.com>
*/
public class JavaUtils
{
+ protected static final Log log = LogFactory.getLog(JavaUtils.class);
+
public static boolean isJBossRepositoryClassLoader(ClassLoader loader)
{
Class clazz = loader.getClass();
@@ -75,4 +84,22 @@
}
}
}
+
+ /**
+ * Convert the SoapMessage object into String.
+ * @param soapMessage
+ * @return
+ */
+ public static String getSoapMessageASString(SOAPMessage soapMessage) {
+ try {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ soapMessage.writeTo(outputStream);
+ byte[] byteArray = outputStream.toByteArray();
+ String soapMsg = new String( byteArray, "UTF-8");
+ return soapMsg;
+ } catch (Exception e) {
+ log.error("Error in converting SOAPMessage into String");
+ }
+ return null;
+ }
}
Modified: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2010-02-23 22:03:13 UTC (rev 506)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2010-02-24 13:39:09 UTC (rev 507)
@@ -30,6 +30,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import javax.wsdl.*;
import javax.wsdl.extensions.ElementExtensible;
@@ -118,7 +119,8 @@
soapMessage,
getSOAPHeaders(bi),
wsdlOperation.getInput().getMessage(),
- odeRequestMessage.getHeaderParts()
+ odeRequestMessage.getHeaderParts(),
+ odeRequestMessage.getMessage()
);
@@ -157,7 +159,8 @@
soapMessage,
getSOAPHeaders(bo),
wsdlOperation.getOutput().getMessage(),
- odeResponseMessage.getHeaderParts()
+ odeResponseMessage.getHeaderParts(),
+ odeResponseMessage.getMessage()
);
@@ -221,7 +224,7 @@
private void createSoapHeaders(SOAPMessage soapMessage, List<SOAPHeader> headers,
javax.wsdl.Message wsdlMessageDef,
- Map<String, Node> headerParts)
+ Map<String, Node> headerParts, Element message)
{
try {
javax.xml.soap.SOAPHeader soapHeader = soapMessage.getSOAPHeader();
@@ -236,6 +239,20 @@
throw new RuntimeException("SOAP header must be a node_element " + headerNode);
}
}
+
+ //Add soap header according to binding.
+ for (SOAPHeader header : headers) {
+ Element headerEl = DOMUtils.findChildByName(message, new QName(null, header.getPart()));
+ if (headerEl != null) {
+ SOAPElement soapHeaderEl = soapFactory.createElement(new QName(header.getMessage().getNamespaceURI(), header.getPart(),"odens"));
+ NodeList list = headerEl.getChildNodes();
+ for(int i=0; i< list.getLength(); i++) {
+ SOAPElement partElement = soapFactory.createElement((Element)list.item(i));
+ soapHeaderEl.addChildElement(partElement);
+ }
+ soapHeader.addChildElement(soapHeaderEl);
+ }
+ }
} catch (SOAPException e) {
throw new RuntimeException("Failed to create soap header",e);
}
Modified: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java 2010-02-23 22:03:13 UTC (rev 506)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java 2010-02-24 13:39:09 UTC (rev 507)
@@ -21,6 +21,22 @@
*/
package org.jboss.soa.bpel.runtime.ws;
+import java.net.URL;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.Message;
@@ -34,21 +50,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.UserTransaction;
-import javax.wsdl.Definition;
-import javax.wsdl.Fault;
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPFault;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.Dispatch;
-import javax.xml.ws.Service;
-import java.net.URL;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-
/**
* Represents a WS invocation.
* Delegates to a JAX-WS {@link javax.xml.ws.Dispatch} implementation.
@@ -131,8 +132,13 @@
SOAPMessage soapRequestMessage = MessageFactory.newInstance().createMessage();
if(log.isDebugEnabled())
log.debug( "ODE outbound message: \n" +DOMWriter.printNode(mex.getRequest().getMessage(), true) );
+
messageAdapter.createSoapRequest(soapRequestMessage, mex.getRequest(), mex.getOperation());
-
+
+ if (log.isDebugEnabled()) {
+ log.debug("Riftsaw soap request message: \n" + JavaUtils.getSoapMessageASString(soapRequestMessage));
+ }
+
// The actual WS invocation
Dispatch proxy = getDispatcher(port);
@@ -214,10 +220,15 @@
SOAPMessage soapRequestMessage = MessageFactory.newInstance().createMessage();
if(log.isDebugEnabled())
log.debug( "ODE outbound message: \n" +DOMWriter.printNode(mex.getRequest().getMessage(), true) );
+
messageAdapter.createSoapRequest(soapRequestMessage, mex.getRequest(), mex.getOperation());
+ if (log.isDebugEnabled()) {
+ log.debug("Riftsaw soap request message: \n" + JavaUtils.getSoapMessageASString(soapRequestMessage));
+ }
+
// The actual WS invocation
- Dispatch proxy = getDispatcher(port);
+ Dispatch proxy = getDispatcher(port);
proxy.invokeOneWay(soapRequestMessage);
tx.commit();