[jboss-svn-commits] JBL Code SVN: r12141 - in labs/jbossesb/trunk/product: core/listeners/tests/src/org/jboss/soa/esb/actions/soap and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 25 12:25:26 EDT 2007
Author: tfennelly
Date: 2007-05-25 12:25:26 -0400 (Fri, 25 May 2007)
New Revision: 12141
Added:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Header.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Order.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/OrderItem.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soap-message-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ESBConfigUtil.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/ESBConfigUtilUnitTest.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/jboss-esb.xml
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/soap/
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java
labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/
labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java
labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/ognl-test-01.xml
labs/jbossesb/trunk/product/lib/ext/wstx-lgpl-3.2.1.jar
Removed:
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/DomUtils.java
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/OGNLUtils.java
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/soap/SOAPClient.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/dom/YADOMUtil.java
labs/jbossesb/trunk/product/services/soapui-client/build.xml
labs/jbossesb/trunk/product/services/soapui-client/pom.xml
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java
Log:
more webservice invocation work
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -3,24 +3,63 @@
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.util.ClassUtil;
import org.jboss.soa.esb.message.Message;
import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.internal.soa.esb.soap.OGNLUtils;
import org.apache.log4j.Logger;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
import javax.management.*;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.namespace.QName;
import java.util.Map;
+import java.util.LinkedHashMap;
import java.io.IOException;
+import java.io.StringReader;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+import com.thoughtworks.xstream.io.xml.QNameMap;
+import com.thoughtworks.xstream.io.xml.StaxDriver;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+
/**
* SOAP Client action processor.
* <p/>
* Uses the SOAPUI Client Service to construct an populate a message
* for the target service. This action then routes that message to the service.
*
+ * <h2>SOAP Request Message Construction</h2>
+ * The message parameters are supplied in one of 2 ways:
+ * <ol>
+ * <li>As a {@link Map} instance set on the <i>default body location</i> (Message.getBody().add(Map))</li>
+ * <li>As a {@link Map} instance set on in a <i>named body location</i> (Message.getBody().add(String, Map)),
+ * where the name of that body location is specified as the value of the "paramsLocation" action property.
+ * </li>
+ * </ol>
+ * The parameter {@link Map} itself can also be populated in one of 2 ways:
+ * <ol>
+ * <li>With a set of Objects that are accessed (for SOAP message parameters) using the
+ * <a href="http://www.ognl.org/">OGNL</a></li> framework. More on the use of OGNL below.
+ * <li>With a set of String based key-value pairs(<String, String>), where the
+ * key is an OGNL expression identifying the SOAP parameter to be populated with
+ * the key's value. More on the use of OGNL below.
+ * </li>
+ * </ol>
+ *
+ *
+ *
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class SOAPClient extends AbstractActionPipelineProcessor {
@@ -30,17 +69,25 @@
private String operation;
private String paramsLocation;
private String responseLocation;
+ private boolean responseAsOgnlMap;
private MBeanServer mbeanServer;
private ObjectName serviceName;
private String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName()};
private String[] getEndpointSig = new String[] {String.class.getName()};
+ private static DocumentBuilderFactory docBuilderFactory = createDocumentBuilderFactory();
+ private XStream responseXStreamDeserialzer;
+ private QNameMap responseXStreamQNameMap = new QNameMap();
public SOAPClient(ConfigTree config) throws ConfigurationException {
wsdl = config.getRequiredAttribute("wsdl");
operation = config.getRequiredAttribute("operation");
paramsLocation = config.getAttribute("paramsLocation");
responseLocation = config.getAttribute("responseLocation");
- mbeanServer = MBeanServerLocator.locate();
+ responseAsOgnlMap = "true".equalsIgnoreCase(config.getAttribute("responseAsOgnlMap"));
+ ConfigTree[] xstreamAliases = config.getChildren("alias");
+ if(xstreamAliases != null && xstreamAliases.length != 0) {
+ configureXStreamDeserializer(xstreamAliases);
+ }
try {
serviceName = new ObjectName("jboss.esb:service=SoapUIClientService");
@@ -49,6 +96,11 @@
}
}
+ public void initialise() throws ActionLifecycleException {
+ super.initialise();
+ mbeanServer = MBeanServerLocator.locate();
+ }
+
public Message process(final Message message) throws ActionProcessingException {
Map params;
@@ -69,12 +121,8 @@
String request = buildRequestMessage(params);
String response = invokeEndpoint(request);
- if(responseLocation != null) {
- message.getBody().add(responseLocation, response);
- } else {
- message.getBody().add(response);
- ActionUtils.setTaskObject(message, response);
- }
+ // And process the response into the message...
+ processResponse(message, response);
return message;
}
@@ -103,14 +151,19 @@
}
}
- private String invokeEndpoint(String request) throws ActionProcessingException {
- PostMethod post = new PostMethod(getEndpoint());
+ protected String invokeEndpoint(String request) throws ActionProcessingException {
+ String endpoint = getEndpoint();
+ PostMethod post = new PostMethod(endpoint);
post.setRequestHeader("SOAPAction", operation);
post.setRequestBody(request);
HttpClient httpclient = new HttpClient();
try {
int result = httpclient.executeMethod(post);
+ if(result != HttpStatus.SC_OK) {
+ // TODO: We need to do more here!!
+ logger.warn("Received status code '" + result + "' on HTTP SOAP (POST) request to '" + endpoint + "'.");
+ }
return post.getResponseBodyAsString();
} catch (IOException e) {
throw new ActionProcessingException("Failed to invoke SOAP Endpoint: '" + getEndpoint() + " ' - '" + operation + "'.", e);
@@ -118,4 +171,136 @@
post.releaseConnection();
}
}
+
+ /**
+ * Process the SOAP response into the ESB Message instance.
+ * @param message The ESB Message.
+ * @param response The SOAP response.
+ * @throws ActionProcessingException Error processing the response.
+ */
+ protected void processResponse(Message message, String response) throws ActionProcessingException {
+ Object responseObject;
+
+ if(responseXStreamDeserialzer != null) {
+ responseObject = applyXStreamResponseDeserializer(response);
+ } else if(responseAsOgnlMap) {
+ responseObject = populateResponseOgnlMap(response);
+ } else {
+ // Otherwise, the response Object is the raw SOAP String...
+ responseObject = response;
+ }
+
+ if(responseLocation != null) {
+ message.getBody().add(responseLocation, responseObject);
+ } else {
+ message.getBody().add(responseObject);
+ ActionUtils.setTaskObject(message, responseObject);
+ }
+ }
+
+ private Object applyXStreamResponseDeserializer(String response) {
+ StaxDriver driver = new StaxDriver(responseXStreamQNameMap);
+ HierarchicalStreamReader responseReader = driver.createReader(new StringReader(response));
+
+ // Move inside the soap body element...
+ responseReader.moveDown();
+ while(!responseReader.getNodeName().toLowerCase().endsWith("body")) {
+ responseReader.moveUp();
+ responseReader.moveDown();
+ }
+ responseReader.moveDown();
+
+ return responseXStreamDeserialzer.unmarshal(responseReader);
+ }
+
+ private Map<String, String> populateResponseOgnlMap(String response) throws ActionProcessingException {
+ Map map = new LinkedHashMap<String, String>();
+
+ try {
+ DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ Document doc = docBuilder.parse(new InputSource(new StringReader(response)));
+ Element graphRootElement = getGraphRootElement(doc.getDocumentElement());
+
+ populateResponseOgnlMap(map, graphRootElement);
+ } catch (ParserConfigurationException e) {
+ throw new ActionProcessingException("Unexpected DOM Parser configuration error.", e);
+ } catch (SAXException e) {
+ throw new ActionProcessingException("Error parsing SOAP response.", e);
+ } catch (IOException e) {
+ throw new ActionProcessingException("Unexpected error reading SOAP response.", e);
+ }
+
+ return map;
+ }
+
+ private void populateResponseOgnlMap(Map<String, String> map, Element element) {
+ NodeList children = element.getChildNodes();
+ int childCount = children.getLength();
+
+ // If the element has a solitary TEXT child, add the text value
+ // against a map key of the elements OGNL expression value.
+ if(childCount == 1) {
+ Node childNode = children.item(0);
+ if(childNode.getNodeType() == Node.TEXT_NODE) {
+ String ognl = OGNLUtils.getOGNLExpression(element);
+ map.put(ognl, childNode.getTextContent());
+ return;
+ }
+ }
+
+ // So the element doesn't contain a solitary TEXT node. Drill down...
+ for(int i = 0; i < childCount; i++) {
+ Node childNode = children.item(i);
+ if(childNode.getNodeType() == Node.ELEMENT_NODE) {
+ populateResponseOgnlMap(map, (Element)childNode);
+ }
+ }
+ }
+
+ private Element getGraphRootElement(Element element) {
+ String ognl = OGNLUtils.getOGNLExpression(element);
+
+ if(ognl != null && !ognl.equals("")) {
+ return element;
+ }
+
+ NodeList children = element.getChildNodes();
+ int childCount = children.getLength();
+ for(int i = 0; i < childCount; i++) {
+ Node node = children.item(i);
+ if(node.getNodeType() == Node.ELEMENT_NODE) {
+ Element graphRootElement = getGraphRootElement((Element)node);
+ if(graphRootElement != null) {
+ return graphRootElement;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private static DocumentBuilderFactory createDocumentBuilderFactory() {
+ DocumentBuilderFactory factory = factory = DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+ factory.setExpandEntityReferences(true);
+
+ return factory;
+ }
+
+ private void configureXStreamDeserializer(ConfigTree[] xstreamAliases) throws ConfigurationException {
+ responseXStreamDeserialzer = new XStream();
+ for(ConfigTree xstreamAlias : xstreamAliases) {
+ String aliasName = xstreamAlias.getRequiredAttribute("name");
+ String aliasTypeName = xstreamAlias.getRequiredAttribute("class");
+ String namespace = xstreamAlias.getRequiredAttribute("namespace");
+
+ try {
+ Class aliasType = ClassUtil.forName(aliasTypeName, getClass());
+ responseXStreamQNameMap.registerMapping(new QName(namespace, aliasName), aliasType);
+ } catch (ClassNotFoundException e) {
+ throw new ConfigurationException("Invalid SOAP response deserializer config. XStream alias type '" + aliasTypeName + "' not found.");
+ }
+ }
+ }
}
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,103 @@
+package org.jboss.soa.esb.actions.soap;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.util.ESBConfigUtil;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.soap.beans.Order;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+
+import java.util.Map;
+
+/**
+ * @author
+ */
+public class SOAPClientUnitTest extends TestCase {
+
+ private ESBConfigUtil configUtil = new ESBConfigUtil(getClass().getResourceAsStream("soapclient-config-01.xml"));
+
+ public void test_XStream_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-01");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ assertEquals(true, message.getBody().get());
+
+ soapClient.processResponse(message, response_02);
+ assertEquals(false, message.getBody().get());
+ }
+
+ public void test_OgnlMap_ResponseProcessing_1() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-02");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ Map<String, String> response = (Map<String, String>) message.getBody().get();
+ assertEquals("true", response.get("customerOrderAck"));
+
+ soapClient.processResponse(message, response_02);
+ response = (Map<String, String>) message.getBody().get();
+ assertEquals("false", response.get("customerOrderAck"));
+ }
+
+ public void test_OgnlMap_ResponseProcessing_2() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-05");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ String responseString = new String(StreamUtils.readStream(getClass().getResourceAsStream("soap-message-01.xml")));
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, responseString);
+ Order order = (Order) message.getBody().get();
+ //assertEquals();
+ System.out.println("sss");
+ }
+
+ public void test_OgnlMap_ResponseProcessing_3() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-02");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ String responseString = new String(StreamUtils.readStream(getClass().getResourceAsStream("soap-message-01.xml")));
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, responseString);
+ Map<String, String> responseMap = (Map<String, String>) message.getBody().get();
+
+ assertEquals("{customerOrder.orderheader.customerName=Tom Fennelly, customerOrder.items[0].partNumber=1, customerOrder.items[0].description=desc-1, customerOrder.items[0].quantity=1, customerOrder.items[0].price=1.1, customerOrder.items[0].extensionAmount=1, customerOrder.items[1].partNumber=2, customerOrder.items[1].description=desc-2, customerOrder.items[1].quantity=2, customerOrder.items[1].price=2.2, customerOrder.items[1].extensionAmount=2}", responseMap.toString());
+ }
+
+ public void test_No_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-03");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ assertEquals(response_01, message.getBody().get());
+ }
+
+ public void test_ResponseLocation() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-04");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ assertEquals(response_01, message.getBody().get("myTestLocation"));
+ }
+
+ private static String response_01 =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+ "\t<soapenv:Header/>\n" +
+ "\t<soapenv:Body>\n" +
+ "\t\t<aetgt:customerOrderAck xmlns:aetgt=\"http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd\">true</aetgt:customerOrderAck>\n" +
+ "\t</soapenv:Body>\n" +
+ "</soapenv:Envelope>";
+ private static String response_02 =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+ "\t<soapenv:Body>\n" +
+ "\t\t<aetgt:customerOrderAck xmlns:aetgt=\"http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd\">false</aetgt:customerOrderAck>\n" +
+ "\t</soapenv:Body>\n" +
+ "</soapenv:Envelope>";
+}
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Header.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Header.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Header.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap.beans;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class Header {
+ private String customerName;
+
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Header.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Order.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Order.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Order.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap.beans;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class Order {
+ private Header header;
+ private List<OrderItem> items;
+
+ public Header getHeader() {
+ return header;
+ }
+
+ public void setHeader(Header header) {
+ this.header = header;
+ }
+
+ public List<OrderItem> getItems() {
+ return items;
+ }
+
+ public void setItems(List<OrderItem> items) {
+ this.items = items;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/Order.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/OrderItem.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/OrderItem.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/OrderItem.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap.beans;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class OrderItem {
+ private int partNumber;
+ private String description;
+ private int quantity;
+ private float price;
+ private int extensionAmount;
+
+ public int getPartNumber() {
+ return partNumber;
+ }
+
+ public void setPartNumber(int partNumber) {
+ this.partNumber = partNumber;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public float getPrice() {
+ return price;
+ }
+
+ public void setPrice(float price) {
+ this.price = price;
+ }
+
+ public int getExtensionAmount() {
+ return extensionAmount;
+ }
+
+ public void setExtensionAmount(int extensionAmount) {
+ this.extensionAmount = extensionAmount;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/beans/OrderItem.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soap-message-01.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soap-message-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soap-message-01.xml 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,27 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" xmlns:stan="http://schemas.active-endpoints.com/sample/standardtypes/2006/04/StandardTypes.xsd">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <cus:customerOrder>
+ <cus:orderheader>
+ <cus:customerName>Tom Fennelly</cus:customerName>
+ </cus:orderheader>
+ <cus:items>
+ <!--1 or more repetitions:-->
+ <cus:item>
+ <cus:partNumber>1</cus:partNumber>
+ <cus:description>desc-1</cus:description>
+ <cus:quantity>1</cus:quantity>
+ <cus:price>1.1</cus:price>
+ <cus:extensionAmount>1</cus:extensionAmount>
+ </cus:item>
+ <cus:item>
+ <cus:partNumber>2</cus:partNumber>
+ <cus:description>desc-2</cus:description>
+ <cus:quantity>2</cus:quantity>
+ <cus:price>2.2</cus:price>
+ <cus:extensionAmount>2</cus:extensionAmount>
+ </cus:item>
+ </cus:items>
+ </cus:customerOrder>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soap-message-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,60 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb
+ xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
+ parameterReloadSecs="5">
+
+ <providers>
+ <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost">
+ <jms-bus busid="OrderNotificationBus">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/OrderNotificationBus"/>
+ </jms-bus>
+ </jms-provider>
+
+ </providers>
+
+ <services>
+
+ <service category="OrderNotificationService" name="OrderNotificationService"
+ description="Order Notification Service">
+ <listeners>
+ <jms-listener name="OrderNotificationService" busidref="OrderNotificationBus"/>
+ </listeners>
+ <actions>
+ <action name="soapui-client-action-01" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="operation" value="ZZZ"/>
+ <property name="responseXStreamConfig">
+ <alias name="customerOrderAck" class="java.lang.Boolean" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
+ </property>
+ </action>
+ <action name="soapui-client-action-02" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="operation" value="ZZZ"/>
+ <property name="responseAsOgnlMap" value="true" />
+ </action>
+ <action name="soapui-client-action-03" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="operation" value="ZZZ"/>
+ </action>
+ <action name="soapui-client-action-04" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="operation" value="ZZZ"/>
+ <property name="responseLocation" value="myTestLocation"/>
+ </action>
+ <action name="soapui-client-action-05" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="operation" value="ZZZ"/>
+ <property name="responseXStreamConfig">
+ <alias name="customerOrder" class="org.jboss.soa.esb.actions.soap.beans.Order" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
+ <alias name="orderheader" class="org.jboss.soa.esb.actions.soap.beans.Header" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
+ <alias name="item" class="org.jboss.soa.esb.actions.soap.beans.OrderItem" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
+ </property>
+ </action>
+ </actions>
+ </service>
+
+ </services>
+
+</jbossesb>
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ESBConfigUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ESBConfigUtil.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ESBConfigUtil.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.util;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.config.Generator;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.xml.sax.SAXException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * Utility class for working with the ESB configuration.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ESBConfigUtil {
+
+ private Document listenerConfig;
+ private Document gatewayConfig;
+
+ public ESBConfigUtil(InputStream esbXsdConfig) {
+ AssertArgument.isNotNull(esbXsdConfig, "esbXsdConfig");
+ ByteArrayOutputStream listenerConfigStream = new ByteArrayOutputStream();
+ ByteArrayOutputStream gatewayConfigStream = new ByteArrayOutputStream();
+ Generator generator = null;
+
+ try {
+ generator = new Generator(esbXsdConfig, listenerConfigStream, gatewayConfigStream);
+ generator.generate();
+ listenerConfig = YADOMUtil.parseStream(new ByteArrayInputStream(listenerConfigStream.toByteArray()), false, false);
+ gatewayConfig = YADOMUtil.parseStream(new ByteArrayInputStream(gatewayConfigStream.toByteArray()), false, false);
+ } catch(Exception e) {
+ e.printStackTrace();
+ TestCase.fail(e.getMessage());
+ }
+ }
+
+ public ConfigTree getListenerConfig(String listenerName) {
+ AssertArgument.isNotNull(listenerName, "listenerName");
+ return ConfigTree.fromElement(getListenerConfig(listenerName, listenerConfig));
+ }
+
+ public ConfigTree getGatewayConfig(String gatewayName) {
+ AssertArgument.isNotNull(gatewayName, "gatewayName");
+ return ConfigTree.fromElement(getListenerConfig(gatewayName, gatewayConfig));
+ }
+
+ private Element getListenerConfig(String name, Document config) {
+ NodeList listenerConfigElements = config.getDocumentElement().getElementsByTagName(name);
+
+ if(listenerConfigElements == null || listenerConfigElements.getLength() == 0) {
+ return null;
+ }
+
+ return (Element) listenerConfigElements.item(0);
+ }
+
+ public ConfigTree getActionConfig(String listenerName, String actionName) {
+ AssertArgument.isNotNull(listenerName, "listenerName");
+ AssertArgument.isNotNull(actionName, "actionName");
+
+ Element listener = getListenerConfig(listenerName, listenerConfig);
+ NodeList actions = listener.getElementsByTagName("action");
+
+ if(actions == null || actions.getLength() == 0) {
+ return null;
+ }
+
+ for(int i = 0; i < actions.getLength(); i++) {
+ Element action = (Element) actions.item(i);
+
+ if(actionName.equals(action.getAttribute("action"))) {
+ return ConfigTree.fromElement(action);
+ }
+ }
+
+ return null;
+ }
+
+
+ public Document getListenerConfig() {
+ return listenerConfig;
+ }
+
+ public Document getGatewayConfig() {
+ return gatewayConfig;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/ESBConfigUtil.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/ESBConfigUtilUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/ESBConfigUtilUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/ESBConfigUtilUnitTest.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,26 @@
+package org.jboss.soa.esb.util.test;
+
+import static java.lang.System.out;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.util.ESBConfigUtil;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.ConfigurationException;
+
+import javax.xml.transform.stream.StreamResult;
+
+/**
+ * @author
+ */
+public class ESBConfigUtilUnitTest extends TestCase {
+
+ public void test() throws ConfigurationException {
+ ESBConfigUtil configUtil = new ESBConfigUtil(getClass().getResourceAsStream("jboss-esb.xml"));
+
+ assertTrue(configUtil.getListenerConfig("JMS-ESBListener").toString().startsWith("<JMS-ESBListener listenerClass=\"org.jboss.soa.esb.listeners.message.MessageAwareListener\" maxThreads=\"1\" service-category=\"ABI_OrderManager\" service-description=\"ABI OrderManager Service\" service-name=\"ABI_OrderManager\">"));
+ assertEquals("<FileGateway URL=\"file:/H:/ae-demo/orders/\" errorDelete=\"false\" errorDir=\"/ae-demo/orders\" errorSuffix=\".IN_ERROR.csv\" gatewayClass=\"org.jboss.soa.esb.listeners.gateway.FileGatewayListener\" inputSuffix=\".in.csv\" maxThreads=\"1\" pollLatencySeconds=\"10\" postDelete=\"false\" postDir=\"/ae-demo/orders\" postSuffix=\".done.csv\" service-description=\"Order Notification Service\" target-service-category=\"OrderNotificationService\" target-service-name=\"OrderNotificationService\" workSuffix=\".esbWorking\"/>", configUtil.getGatewayConfig("FileGateway").toString());
+ assertEquals("<action action=\"print-after-transform\" class=\"org.jboss.soa.esb.actions.SystemPrintln\" message=\"[Quickstart_webservice_bpel] Message after transform and before SOAPClient\"/>", configUtil.getActionConfig("OrderNotificationService", "print-after-transform").toString());
+ }
+
+
+}
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/ESBConfigUtilUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/jboss-esb.xml (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/jboss-esb.xml 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,142 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb
+ xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
+ parameterReloadSecs="5">
+
+ <providers>
+ <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost">
+
+ <jms-bus busid="OrderManagerGateway">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_bpel_gw"/>
+ </jms-bus>
+ <jms-bus busid="OrderManagerService">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_bpel_esb"
+ selector="service='ordermanager'"/>
+ </jms-bus>
+ <jms-bus busid="ShipperService">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_bpel_esb"
+ selector="service='shipper'"/>
+ </jms-bus>
+ <jms-bus busid="OrderNotificationService">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_bpel_esb"
+ selector="service='orderNotifier'"/>
+ </jms-bus>
+ </jms-provider>
+
+ <jbr-provider name="JBR-Http-1" protocol="http" host="localhost">
+ <jbr-bus busid="Http-1" port="8865"/>
+ </jbr-provider>
+
+ <jbr-provider name="JBR-Http-2" protocol="http" host="localhost">
+ <jbr-bus busid="Http-2" port="8866"/>
+ </jbr-provider>
+
+ <jbr-provider name="JBR-Socket" protocol="socket" host="localhost">
+ <jbr-bus busid="Socket-1" port="8988"/>
+ </jbr-provider>
+
+ <fs-provider name="File Sys Provider">
+ <fs-bus busid="notificationChannel">
+ <fs-message-filter
+ directory="/ae-demo/orders"
+ input-suffix=".in.csv"
+ work-suffix=".esbWorking"
+ post-delete="false"
+ post-directory="/ae-demo/orders"
+ post-suffix=".done.csv"
+ error-delete="false"
+ error-directory="/ae-demo/orders"
+ error-suffix=".IN_ERROR.csv"
+ />
+ </fs-bus>
+ </fs-provider>
+
+ </providers>
+
+ <services>
+
+ <service category="ABI_OrderManager" name="ABI_OrderManager" description="ABI OrderManager Service">
+
+ <listeners>
+ <jms-listener name="JMS-Gateway" busidref="OrderManagerGateway" is-gateway="true" maxThreads="1"/>
+ <jbr-listener name="Http-Gateway" busidref="Http-1" is-gateway="true" maxThreads="1"/>
+ <jbr-listener name="Socket-Gateway" busidref="Socket-1" is-gateway="true" maxThreads="1"/>
+
+ <jms-listener name="JMS-ESBListener" busidref="OrderManagerService" maxThreads="1"/>
+ </listeners>
+ <actions>
+ <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message"
+ value="[Quickstart_webservice_bpel] Message before invoking 'ABI_OrderManager' endpoint"/>
+ </action>
+ <action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.JBossWSAdapter">
+ <property name="jbossws-endpoint" value="ABI_OrderManager"/>
+ </action>
+ <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message"
+ value="[Quickstart_webservice_bpel] Message after invoking 'ABI_OrderManager' endpoint"/>
+ </action>
+ </actions>
+ </service>
+
+ <service category="ABI_Shipper" name="ABI_Shipper" description="ABI Shipper Service">
+
+ <listeners>
+ <jbr-listener name="Http-Gateway" busidref="Http-2" is-gateway="true" maxThreads="1"/>
+
+ <jms-listener name="JMS-ESBListener" busidref="ShipperService" maxThreads="1"/>
+ </listeners>
+ <actions>
+ <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message"
+ value="[Quickstart_webservice_bpel] Message before invoking 'ABI_Shipping' endpoint"/>
+ </action>
+ <action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.JBossWSAdapter">
+ <property name="jbossws-endpoint" value="ABI_Shipping"/>
+ </action>
+ <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message"
+ value="[Quickstart_webservice_bpel] Message after invoking 'ABI_Shipping' endpoint"/>
+ </action>
+ </actions>
+ </service>
+
+ <service category="OrderNotificationService" name="OrderNotificationService"
+ description="Order Notification Service">
+ <listeners>
+ <fs-listener name="FileGateway" busidref="notificationChannel" is-gateway="true"
+ poll-frequency-seconds="10"/>
+ <jms-listener name="OrderNotificationService" busidref="OrderNotificationService"/>
+ </listeners>
+ <actions>
+ <!-- Transform the incoming CSV order approval record into a populated
+ com.activebpel.ordermanagement.SalesOrderNotification instance. -->
+ <action name="message-populator" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
+ <property name="from" value="OrderManager"/>
+ <property name="from-type" value="text/csv:orderApproval"/>
+ <property name="to" value="RetailerCallback"/>
+ <property name="to-type" value="text/xml:SendSalesOrderNotification"/>
+ </action>
+ <action name="print-after-transform" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="[Quickstart_webservice_bpel] Message after transform and before SOAPClient"/>
+ </action>
+ <!-- Inject the com.activebpel.ordermanagement.SalesOrderNotification instance
+ into the SOAPClient. SOAPClient will use SOAPUI to construct a soap request
+ template and will then use OGNL to populate the values (from the Smooks
+ EXTRACTED_BEANS_HASH) into the soap message. -->
+ <action name="soapui-client" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="operation" value="SendSalesOrderNotification"/>
+ <property name="paramsLocation" value="EXTRACTED_BEANS_HASH"/>
+ <property name="responseXStreamConfig">
+ <alias name="customerOrderAck" class="java.lang.Boolean" />
+ </property>
+ </action>
+ </actions>
+ </service>
+
+ </services>
+
+</jbossesb>
Property changes on: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/util/test/jboss-esb.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,123 @@
+package org.jboss.internal.soa.esb.soap;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Comment;
+import org.jboss.soa.esb.dom.YADOMUtil;
+
+import java.util.Map;
+
+import ognl.Ognl;
+import ognl.OgnlException;
+
+/**
+ * OGNL Utilities for SOAP message processing.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class OGNLUtils {
+
+ private static Logger logger = Logger.getLogger(OGNLUtils.class);
+ public static final String JBOSSESB_SOAP_NS = "http://jbossesb.jboss.org/soap";
+ public static final String JBOSSESB_SOAP_NS_PREFIX = "jbossesb-soap:";
+ public static final String OGNL_ATTRIB = "ognl";
+ public static final String IS_COLLECTION_ATTRIB = "is-collection";
+
+ public static Object getParameter(String ognl, Map params) {
+ Object param;
+
+ // Try getting the parameter from the params Map using the
+ // raw OGNL expression as the key...
+ param = params.get(ognl);
+ if(param == null) {
+ // And if that didn't work, try using the OGNL expression to extract the param
+ // from an Object Graph using the OGNL toolkit...
+ try {
+ param = Ognl.getValue(ognl, params);
+ } catch (OgnlException ex) {
+ if(logger.isDebugEnabled()) {
+ logger.debug("OGNL Error.", ex);
+ }
+ }
+ }
+
+ return (param != null?param:"");
+ }
+
+ public static String getOGNLExpression(Element element) {
+ StringBuffer ognlExpression = new StringBuffer();
+ Node parent = element.getParentNode();
+ boolean isCollection;
+ boolean isInBody = false;
+
+ ognlExpression.append(getOGNLToken(element));
+
+ while (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
+ Element parentElement = (Element) parent;
+ String parentName = YADOMUtil.getName(parentElement);
+
+ if (parentName.equalsIgnoreCase("body") &&
+ parent.getNamespaceURI().equalsIgnoreCase("http://schemas.xmlsoap.org/soap/envelope/")) {
+ isInBody = true;
+ break;
+ }
+
+ String preassignedOgnl = parentElement.getAttributeNS(JBOSSESB_SOAP_NS, OGNL_ATTRIB);
+ if(preassignedOgnl != null && !preassignedOgnl.equals("")) {
+ ognlExpression.insert(0, "." + preassignedOgnl);
+ isInBody = true;
+ break;
+ } else {
+ ognlExpression.insert(0, getOGNLToken(parentElement));
+ }
+ parent = parent.getParentNode();
+ }
+
+ if(!isInBody) {
+ return "";
+ }
+
+ // Remove the leading '.'
+ ognlExpression.deleteCharAt(0);
+
+ return ognlExpression.toString();
+ }
+
+ public static String getOGNLToken(Element element) {
+ String localName = element.getLocalName();
+ String ognlToken;
+
+ if (assertIsParentCollection(element)) {
+ int count = YADOMUtil.countElementsBefore(element, element.getTagName());
+ ognlToken = "[" + count + "]";
+ } else {
+ ognlToken = "." + localName;
+ }
+
+ return ognlToken;
+ }
+
+ private static boolean assertIsCollection(Element element) {
+ if(element.getAttributeNS(JBOSSESB_SOAP_NS, IS_COLLECTION_ATTRIB).equals("true")) {
+ // It's already been attributed... no need to check for the soapui comment...
+ return true;
+ }
+
+ Comment firstComment = (Comment) YADOMUtil.getFirstChildByType(element, Node.COMMENT_NODE);
+
+ // TODO: Get Ole (soapUI) to add an attribute to the collection element - better than looking for this comment.
+ if(firstComment != null && firstComment.getTextContent().indexOf("1 or more repetitions") != -1) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private static boolean assertIsParentCollection(Element element) {
+ Node parent = element.getParentNode();
+ if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE && assertIsCollection((Element)parent)) {
+ return true;
+ }
+ return false;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/dom/YADOMUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/dom/YADOMUtil.java 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/dom/YADOMUtil.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -26,6 +26,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.List;
+import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -36,13 +38,14 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPathFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathConstants;
import org.jboss.soa.esb.ConfigurationException;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.w3c.dom.*;
import org.xml.sax.SAXException;
/**
@@ -89,6 +92,8 @@
/**
* Parse the XML stream and return the associated W3C Document object.
+ * <p/>
+ * Performs a namespace unaware parse.
*
* @param stream
* The stream to be parsed.
@@ -101,6 +106,26 @@
*/
public static Document parseStream(InputStream stream, boolean validate,
boolean expandEntityRefs) throws SAXException, IOException {
+ return parseStream(stream, validate, expandEntityRefs, false);
+ }
+
+ /**
+ * Parse the XML stream and return the associated W3C Document object.
+ *
+ * @param stream
+ * The stream to be parsed.
+ * @param validate
+ * True if the document is to be validated, otherwise false.
+ * @param expandEntityRefs
+ * Expand entity References as per
+ * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean)}.
+ * @param namespaceAware
+ * True if the document parse is to be namespace aware,
+ * otherwise false.
+ * @return The W3C Document object associated with the input stream.
+ */
+ public static Document parseStream(InputStream stream, boolean validate,
+ boolean expandEntityRefs, boolean namespaceAware) throws SAXException, IOException {
if (stream == null) {
throw new IllegalArgumentException(
"null 'stream' arg in method call.");
@@ -112,6 +137,7 @@
factory.setValidating(validate);
factory.setExpandEntityReferences(expandEntityRefs);
+ factory.setNamespaceAware(namespaceAware);
docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(stream);
@@ -214,4 +240,176 @@
throw new ConfigurationException("Failed to serialize ESB Configuration Document instance.", e);
}
}
+
+ /**
+ * Count the DOM element nodes before the supplied node, having the specified
+ * tag name, not including the node itself.
+ * <p/>
+ * Counts the sibling nodes.
+ *
+ * @param node Node whose element siblings are to be counted.
+ * @param tagName The tag name of the sibling elements to be counted.
+ * @return The number of siblings elements before the supplied node with the
+ * specified tag name.
+ */
+ public static int countElementsBefore(Node node, String tagName) {
+ Node parent = node.getParentNode();
+
+ NodeList siblings = parent.getChildNodes();
+ int count = 0;
+ int siblingCount = siblings.getLength();
+
+ for (int i = 0; i < siblingCount; i++) {
+ Node sibling = siblings.item(i);
+
+ if (sibling == node) {
+ break;
+ }
+ if (sibling.getNodeType() == Node.ELEMENT_NODE && ((Element) sibling).getTagName().equals(tagName)) {
+ count++;
+ }
+ }
+
+ return count;
+ }
+
+ /**
+ * Copy the nodes of a NodeList into the supplied list.
+ * <p/>
+ * This is not a cloneCollectionTemplateElement. It's just a copy of the node references.
+ * <p/>
+ * Allows iteration over the Nodelist using the copy in the knowledge that
+ * the list will remain the same length, even if we modify the underlying NodeList.
+ * Using the NodeList can result in problems because elements can get removed from
+ * the list while we're iterating over it.
+ * <p/>
+ * <i>This code was acquired donated by the Milyn Smooks project.</i>
+ *
+ * @param nodeList Nodelist to copy.
+ * @return List copy.
+ */
+ public static List<Node> copyNodeList(NodeList nodeList) {
+ List<Node> copy = new Vector<Node>();
+
+ if (nodeList != null) {
+ int nodeCount = nodeList.getLength();
+
+ for (int i = 0; i < nodeCount; i++) {
+ copy.add(nodeList.item(i));
+ }
+ }
+
+ return copy;
+ }
+
+ public static Element getNextSiblingElement(Node node) {
+ Node nextSibling = node.getNextSibling();
+
+ while (nextSibling != null) {
+ if (nextSibling.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) nextSibling;
+ }
+ nextSibling = nextSibling.getNextSibling();
+ }
+
+ return null;
+ }
+
+ public static Node getFirstChildByType(Element element, int nodeType) {
+ NodeList children = element.getChildNodes();
+ int childCount = children.getLength();
+
+ for(int i = 0; i < childCount; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == nodeType) {
+ return child;
+ }
+ }
+
+ return null;
+ }
+
+ private static String ELEMENT_NAME_FUNC = "/name()";
+
+ private static XPathFactory xPathFactory = XPathFactory.newInstance();
+
+ /**
+ * Get the W3C NodeList instance associated with the XPath selection
+ * supplied.
+ * <p/>
+ * <b>NOTE</b>: Taken from Milyn Commons.
+ *
+ * @param node The document node to be searched.
+ * @param xpath The XPath String to be used in the selection.
+ * @return The W3C NodeList instance at the specified location in the
+ * document, or null.
+ */
+ public static NodeList getNodeList(Node node, String xpath) {
+ if (node == null) {
+ throw new IllegalArgumentException(
+ "null 'document' arg in method call.");
+ } else if (xpath == null) {
+ throw new IllegalArgumentException(
+ "null 'xpath' arg in method call.");
+ }
+ try {
+ XPath xpathEvaluater = xPathFactory.newXPath();
+
+ if (xpath.endsWith(ELEMENT_NAME_FUNC)) {
+ return (NodeList) xpathEvaluater.evaluate(xpath.substring(0,
+ xpath.length() - ELEMENT_NAME_FUNC.length()), node,
+ XPathConstants.NODESET);
+ } else {
+ return (NodeList) xpathEvaluater.evaluate(xpath, node,
+ XPathConstants.NODESET);
+ }
+ } catch (XPathExpressionException e) {
+ throw new IllegalArgumentException("bad 'xpath' expression ["
+ + xpath + "].");
+ }
+ }
+
+ /**
+ * Get the W3C Node instance associated with the XPath selection supplied.
+ * <p/>
+ * <b>NOTE</b>: Taken from Milyn Commons.
+ *
+ * @param node The document node to be searched.
+ * @param xpath The XPath String to be used in the selection.
+ * @return The W3C Node instance at the specified location in the document,
+ * or null.
+ */
+ public static Node getNode(Node node, String xpath) {
+ NodeList nodeList = getNodeList(node, xpath);
+
+ if (nodeList == null || nodeList.getLength() == 0) {
+ return null;
+ } else {
+ return nodeList.item(0);
+ }
+ }
+
+ /**
+ * Get the name from the supplied element.
+ * <p/>
+ * Returns the {@link Node#getLocalName() localName} of the element
+ * if set (namespaced element), otherwise the
+ * element's {@link Element#getTagName() tagName} is returned.
+ * <p/>
+ * <b>NOTE</b>: Taken from Milyn Smooks.
+ *
+ * @param element The element.
+ * @return The element name.
+ */
+ public static String getName(Element element) {
+ AssertArgument.isNotNull(element, "element");
+
+ String name = element.getLocalName();
+
+ if(name != null) {
+ return name;
+ } else {
+ return element.getTagName();
+ }
+ }
}
Added: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.soap;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.ConfigurationException;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import javax.xml.xpath.XPathFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class OGNLUtilsUnitTest extends TestCase {
+
+ public void test() throws IOException, SAXException, ConfigurationException, XPathExpressionException {
+ Node node;
+
+ // Test regular node...
+ node = getNode("/soapenv:Envelope/soapenv:Body/cus:customerOrder/cus:header/cus:customerName");
+ assertEquals("customerOrder.header.customerName", OGNLUtils.getOGNLExpression((Element) node));
+
+ // Test collection nodes...
+ node = getNode("/soapenv:Envelope/soapenv:Body/cus:customerOrder/cus:items/cus:item[1]");
+ assertEquals("customerOrder.items[0]", OGNLUtils.getOGNLExpression((Element) node));
+
+ node = getNode("/soapenv:Envelope/soapenv:Body/cus:customerOrder/cus:items/cus:item[2]");
+ assertEquals("customerOrder.items[1]", OGNLUtils.getOGNLExpression((Element) node));
+
+ node = getNode("/soapenv:Envelope/soapenv:Body/cus:customerOrder/cus:items/cus:item[2]/cus:partNumber");
+ assertEquals("customerOrder.items[1].partNumber", OGNLUtils.getOGNLExpression((Element) node));
+ }
+
+ private Node getNode(String xpath) throws IOException, SAXException, XPathExpressionException {
+ Document order = YADOMUtil.parseStream(getClass().getResourceAsStream("ognl-test-01.xml"), false, false, true);
+ XPathFactory xPathFactory = XPathFactory.newInstance();
+ XPath xpathEvaluater = xPathFactory.newXPath();
+
+ xpathEvaluater.setNamespaceContext(new MockNamespaceContext());
+
+ return (Node) xpathEvaluater.evaluate(xpath, order, XPathConstants.NODE);
+ }
+
+ class MockNamespaceContext implements NamespaceContext {
+
+ private Map<String, String> namespaces = new HashMap<String, String>();
+ private Map<String, String> prefixes = new HashMap<String, String>();
+
+ public MockNamespaceContext() {
+ namespaces.put("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
+ namespaces.put("cus", "http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd");
+ namespaces.put("stan", "http://schemas.active-endpoints.com/sample/standardtypes/2006/04/StandardTypes.xsd");
+ prefixes.put("http://schemas.xmlsoap.org/soap/envelope/", "soapenv");
+ prefixes.put("http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd", "cus");
+ prefixes.put("http://schemas.active-endpoints.com/sample/standardtypes/2006/04/StandardTypes.xsd", "stan");
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return namespaces.get(prefix);
+ }
+
+ public String getPrefix(String namespaceURI) {
+ return prefixes.get(namespaceURI);
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ ArrayList list = new ArrayList();
+
+ if(prefixes.containsKey(namespaceURI)) {
+ list.add(prefixes.get(namespaceURI));
+ }
+
+ return list.iterator();
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/ognl-test-01.xml
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/ognl-test-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/ognl-test-01.xml 2007-05-25 16:25:26 UTC (rev 12141)
@@ -0,0 +1,27 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" xmlns:stan="http://schemas.active-endpoints.com/sample/standardtypes/2006/04/StandardTypes.xsd">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <cus:customerOrder>
+ <cus:header>
+ <cus:customerName>?</cus:customerName>
+ </cus:header>
+ <cus:items>
+ <!--1 or more repetitions:-->
+ <cus:item>
+ <cus:partNumber>?</cus:partNumber>
+ <cus:description>?</cus:description>
+ <cus:quantity>?</cus:quantity>
+ <cus:price>?</cus:price>
+ <cus:extensionAmount>?</cus:extensionAmount>
+ </cus:item>
+ <cus:item>
+ <cus:partNumber>?</cus:partNumber>
+ <cus:description>?</cus:description>
+ <cus:quantity>?</cus:quantity>
+ <cus:price>?</cus:price>
+ <cus:extensionAmount>?</cus:extensionAmount>
+ </cus:item>
+ </cus:items>
+ </cus:customerOrder>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/soap/ognl-test-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/lib/ext/wstx-lgpl-3.2.1.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/lib/ext/wstx-lgpl-3.2.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/trunk/product/services/soapui-client/build.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/build.xml 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/services/soapui-client/build.xml 2007-05-25 16:25:26 UTC (rev 12141)
@@ -8,10 +8,15 @@
<property name="maven.build.final.name" value="soapui-client"/>
<property name="maven.test.reports" value="${maven.build.directory}/test-reports"/>
<property name="maven.test.output" value="target/test-classes"/>
+
+ <fileset id="jboss-esb-dependencies" dir="../../build/jbossesb/lib" includes="jbossesb-rosetta.jar" />
+
<path id="build.classpath">
<fileset dir="src/lib" includes="*.jar" />
<fileset dir="../../lib/ext" includes="*.jar" />
+ <fileset refid="jboss-esb-dependencies" />
</path>
+
<target name="clean" description="Clean the output directory">
<delete dir="${maven.build.directory}"/>
</target>
@@ -43,6 +48,7 @@
<copy todir="${maven.build.directory}/sar">
<fileset dir="src" includes="lib/*.jar" excludes="lib/jboss-*.jar" />
<fileset dir="src/main/resources" />
+ <fileset refid="jboss-esb-dependencies" />
</copy>
<copy todir="${maven.build.directory}/sar">
<!-- fileset dir="${maven.build.directory}" includes="${maven.build.final.name}.jar" / -->
Modified: labs/jbossesb/trunk/product/services/soapui-client/pom.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/pom.xml 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/services/soapui-client/pom.xml 2007-05-25 16:25:26 UTC (rev 12141)
@@ -44,6 +44,13 @@
</dependency>
<dependency>
<groupId>jboss</groupId>
+ <artifactId>jbossesb-rosetta</artifactId>
+ <version>4.0.x</version>
+ <systemPath>${basedir}/../../build/jbossesb/lib/jbossesb-rosetta.jar</systemPath>
+ <scope>system</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
<artifactId>jboss-system</artifactId>
<version>4.0.x</version>
<systemPath>${basedir}/src/lib/jboss-system.jar</systemPath>
@@ -60,7 +67,7 @@
<groupId>jboss</groupId>
<artifactId>jbossall-client</artifactId>
<version>4.0.x</version>
- <systemPath>${basedir}/../../../../lib/ext/jbossall-client.jar</systemPath>
+ <systemPath>${basedir}/../../lib/ext/jbossall-client.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
@@ -83,8 +90,12 @@
<artifactId>ognl</artifactId>
<version>2.6.9</version>
</dependency>
-
<dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1</version>
Deleted: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/DomUtils.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/DomUtils.java 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/DomUtils.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -1,108 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.services.soapui;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Element;
-
-import java.util.List;
-import java.util.Vector;
-
-/**
- * DOM utility methods for the SOAPUI client.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class DomUtils {
- /**
- * Count the DOM element nodes before the supplied node, having the specified
- * tag name, not including the node itself.
- * <p/>
- * Counts the sibling nodes.
- *
- * @param node Node whose element siblings are to be counted.
- * @param tagName The tag name of the sibling elements to be counted.
- * @return The number of siblings elements before the supplied node with the
- * specified tag name.
- */
- protected static int countElementsBefore(Node node, String tagName) {
- Node parent = node.getParentNode();
-
- NodeList siblings = parent.getChildNodes();
- int count = 0;
- int siblingCount = siblings.getLength();
-
- for (int i = 0; i < siblingCount; i++) {
- Node sibling = siblings.item(i);
-
- if (sibling == node) {
- break;
- }
- if (sibling.getNodeType() == Node.ELEMENT_NODE && ((Element) sibling).getTagName().equals(tagName)) {
- count++;
- }
- }
-
- return count;
- }
-
- /**
- * Copy the nodes of a NodeList into the supplied list.
- * <p/>
- * This is not a cloneCollectionTemplateElement. It's just a copy of the node references.
- * <p/>
- * Allows iteration over the Nodelist using the copy in the knowledge that
- * the list will remain the same length, even if we modify the underlying NodeList.
- * Using the NodeList can result in problems because elements can get removed from
- * the list while we're iterating over it.
- * <p/>
- * <i>This code was acquired donated by the Milyn Smooks project.</i>
- *
- * @param nodeList Nodelist to copy.
- * @return List copy.
- */
- public static List<Node> copyNodeList(NodeList nodeList) {
- List<Node> copy = new Vector<Node>();
-
- if (nodeList != null) {
- int nodeCount = nodeList.getLength();
-
- for (int i = 0; i < nodeCount; i++) {
- copy.add(nodeList.item(i));
- }
- }
-
- return copy;
- }
-
- protected static Element getNextSiblingElement(Node node) {
- Node nextSibling = node.getNextSibling();
-
- while (nextSibling != null) {
- if (nextSibling.getNodeType() == Node.ELEMENT_NODE) {
- return (Element) nextSibling;
- }
- nextSibling = nextSibling.getNextSibling();
- }
-
- return null;
- }
-}
Deleted: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/OGNLUtils.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/OGNLUtils.java 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/OGNLUtils.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -1,98 +0,0 @@
-/*
- Milyn - Copyright (C) 2006
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License (version 2.1) as published by the Free Software
- Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- See the GNU Lesser General Public License for more details:
- http://www.gnu.org/licenses/lgpl.txt
-*/
-package org.jboss.soa.esb.services.soapui;
-
-import ognl.Ognl;
-import ognl.OgnlException;
-
-import java.util.Map;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.apache.log4j.Logger;
-
-/**
- * OGNL Utilities for the SOAP UI Client service.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public abstract class OGNLUtils {
-
- private static Logger logger = Logger.getLogger(OGNLUtils.class);
-
- public static Object getParameter(String ognl, Map params) {
- Object param;
-
- // Try getting the parameter from the params Map using the
- // raw OGNL expression as the key...
- param = params.get(ognl);
- if(param == null) {
- // And if that didn't work, try using the OGNL expression to extract the param
- // from an Object Graph using the OGNL toolkit...
- try {
- param = Ognl.getValue(ognl, params);
- } catch (OgnlException ex) {
- if(logger.isDebugEnabled()) {
- logger.debug("OGNL Error.", ex);
- }
- }
- }
-
- return (param != null?param:"");
- }
-
- public static String getOGNLExpression(Element element) {
- StringBuffer xpath = new StringBuffer();
- Node parent = element.getParentNode();
-
- xpath.append(getOGNLToken(element));
-
- while (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- if (parent.getLocalName().equalsIgnoreCase("body") &&
- parent.getNamespaceURI().equalsIgnoreCase("http://schemas.xmlsoap.org/soap/envelope/")) {
- break;
- }
-
- Element parentElement = (Element) parent;
- String preassignedOgnl = parentElement.getAttributeNS(SoapUIClientService.SOAPUICL_NS, SoapUIClientService.OGNL_ATTRIB);
- if(preassignedOgnl != null && !preassignedOgnl.equals("")) {
- xpath.insert(0, "." + preassignedOgnl);
- break;
- } else {
- xpath.insert(0, getOGNLToken(parentElement));
- }
- parent = parent.getParentNode();
- }
-
- // Remove the leading '.'
- xpath.deleteCharAt(0);
-
- return xpath.toString();
- }
-
- public static String getOGNLToken(Element element) {
- String localName = element.getLocalName();
- int count = DomUtils.countElementsBefore(element, element.getTagName());
- String xpathToken;
-
- if (count > 0) {
- xpathToken = "." + localName + "[" + (count + 1) + "]";
- } else {
- xpathToken = "." + localName;
- }
-
- return xpathToken;
- }
-}
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -28,6 +28,8 @@
import java.util.*;
import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.internal.soa.esb.soap.OGNLUtils;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import org.milyn.xml.XmlUtil;
@@ -44,10 +46,7 @@
*/
public class SoapUIClientService extends ServiceMBeanSupport implements SoapUIClientServiceMBean {
- protected static final String SOAPUICL_NS = "http://jbossesb.jboss.org/soapui-client";
- protected static final String SOAPUICL_NS_PREFIX = "soapui:";
- protected static final String IS_CLONE_ATTRIB = "is-clone";
- protected static final String OGNL_ATTRIB = "ognl";
+ private static final String IS_CLONE_ATTRIB = "is-clone";
private static Logger logger = Logger.getLogger(SoapUIClientService.class);
private Map<String, WsdlInterface[]> wsdls = new HashMap<String, WsdlInterface[]>();
private DocumentBuilder docBuilder;
@@ -82,22 +81,6 @@
}
/**
- * Populate the supplied SOAP responseObject from the supplied soapMessage.
- *
- * @param wsdl WSDL URL.
- * @param operation Operation name.
- * @param soapMessage The soap message containing the data.
- * @param responseObject The soap response object to be populated fromthe data in the soap message.
- * @return The populated responseObject, or a fault object if the message contains a fault.
- * @throws IOException Failed to load WSDL.
- * @throws UnsupportedOperationException Operation not supported on specified WSDL.
- * @throws SAXException Failed to parse the SOAP message.
- */
- public Object populateResponse(String wsdl, String operation, String soapMessage, Object responseObject) throws IOException, UnsupportedOperationException, SAXException {
- throw new UnsupportedOperationException("Not yet implemented!");
- }
-
- /**
* Get the 1st endpoint from the specified WSDL.
*
* @param wsdl WSDL URL.
@@ -141,6 +124,7 @@
private String injectParameters(String soapMessage, Map params) throws IOException, SAXException {
Document messageDoc = docBuilder.parse(new ByteArrayInputStream(soapMessage.getBytes()));
+
Element docRoot = messageDoc.getDocumentElement();
expandMessage(docRoot, params);
@@ -161,9 +145,10 @@
private void expandMessage(Element element, Map params) {
// If this element is not a cloned element, check does it need to be cloned...
- if(!element.hasAttributeNS(SOAPUICL_NS, IS_CLONE_ATTRIB)) {
+ if(!element.hasAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, IS_CLONE_ATTRIB)) {
String ognl = OGNLUtils.getOGNLExpression(element);
Object param;
+
param = OGNLUtils.getParameter(ognl, params);
if(param != null) {
Class paramRuntime = param.getClass();
@@ -183,7 +168,7 @@
}
// Now do the same for the child elements...
- List<Node> children = DomUtils.copyNodeList(element.getChildNodes());
+ List<Node> children = YADOMUtil.copyNodeList(element.getChildNodes());
for (Node node : children) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
expandMessage((Element) node, params);
@@ -200,7 +185,7 @@
if(firstNode.getNodeType() == Node.ELEMENT_NODE) {
firstElement = (Element)firstNode;
} else {
- firstElement = DomUtils.getNextSiblingElement(firstNode);
+ firstElement = YADOMUtil.getNextSiblingElement(firstNode);
}
}
@@ -229,21 +214,21 @@
return;
}
- Element nextSibling = DomUtils.getNextSiblingElement(element);
+ Element nextSibling = YADOMUtil.getNextSiblingElement(element);
Node parent = element.getParentNode();
- element.setAttributeNS(SOAPUICL_NS, SOAPUICL_NS_PREFIX + OGNL_ATTRIB, ognl + "[0]");
+ element.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[0]");
for(int i = 0; i < cloneCount; i++) {
Element clone = (Element) element.cloneNode(true);
- clone.setAttributeNS(SOAPUICL_NS, SOAPUICL_NS_PREFIX + IS_CLONE_ATTRIB, "true");
- clone.setAttributeNS(SOAPUICL_NS, SOAPUICL_NS_PREFIX + OGNL_ATTRIB, ognl + "[" + Integer.toString(i + 1) + "]");
+ clone.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + IS_CLONE_ATTRIB, "true");
+ clone.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[" + Integer.toString(i + 1) + "]");
if(nextSibling == null) {
parent.appendChild(clone);
} else {
parent.insertBefore(clone, nextSibling);
}
- nextSibling = DomUtils.getNextSiblingElement(clone);
+ nextSibling = YADOMUtil.getNextSiblingElement(clone);
}
}
@@ -269,8 +254,8 @@
}
}
- element.removeAttributeNS(SOAPUICL_NS, IS_CLONE_ATTRIB);
- element.removeAttributeNS(SOAPUICL_NS, OGNL_ATTRIB);
+ element.removeAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, IS_CLONE_ATTRIB);
+ element.removeAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.OGNL_ATTRIB);
}
}
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2007-05-25 14:43:34 UTC (rev 12140)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2007-05-25 16:25:26 UTC (rev 12141)
@@ -50,20 +50,6 @@
public abstract String buildRequest(String wsdl, String operation, Map params) throws IOException, UnsupportedOperationException, SAXException;
/**
- * Populate the supplied SOAP responseObject from the supplied soapMessage.
- *
- * @param wsdl WSDL URL.
- * @param operation Operation name.
- * @param soapMessage The soap message containing the data.
- * @param responseObject The soap response object to be populated fromthe data in the soap message.
- * @return The populated responseObject, or a fault object if the message contains a fault.
- * @throws IOException Failed to load WSDL.
- * @throws UnsupportedOperationException Operation not supported on specified WSDL.
- * @throws SAXException Failed to parse the SOAP message.
- */
- public abstract Object populateResponse(String wsdl, String operation, String soapMessage, Object responseObject) throws IOException, UnsupportedOperationException, SAXException;
-
- /**
* Get the 1st endpoint from the specified WSDL.
*
* @param wsdl WSDL URL.
More information about the jboss-svn-commits
mailing list