[jboss-svn-commits] JBL Code SVN: r13965 - in labs/jbossesb/trunk/product: rosetta/tests/src/org/jboss/internal/soa/esb/soap and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 2 10:16:44 EDT 2007
Author: beve
Date: 2007-08-02 10:16:43 -0400 (Thu, 02 Aug 2007)
New Revision: 13965
Added:
labs/jbossesb/trunk/product/services/soapui-client/src/lib/jboss-common.jar
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
labs/jbossesb/trunk/product/services/soapui-client/build.xml
labs/jbossesb/trunk/product/services/soapui-client/src/lib/xbean-2.2.0.jar
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
labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
Log:
Work for JBESB-751 "SOAPClient: add a SOAP namespace property to the configuration"
Also removed javax.xml.namespace.QName from xbean-2.2.o.jar as this was causing problems when running soapui-client scoped.
Also added jboss-common.jar so that avoid errors upon startup and init of log4j (this is the reason build.xml was modified)
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/soap/OGNLUtils.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -22,6 +22,24 @@
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";
+
+ private enum SOAPNameSpaces
+ {
+ SOAP_1_1("http://schemas.xmlsoap.org/soap/envelope/"),
+ SOAP_1_2("http://www.w3.org/2003/05/soap-envelope");
+
+ private String nameSpace;
+
+ SOAPNameSpaces( final String nameSpace )
+ {
+ this.nameSpace = nameSpace;
+ }
+
+ public String getNameSpace()
+ {
+ return nameSpace;
+ }
+ }
public static Object getParameter(String ognl, Map params) {
Object param;
@@ -43,8 +61,12 @@
return (param != null?param:"");
}
+
+ public static String getOGNLExpression(Element element ) {
+ return getOGNLExpression( element, null );
+ }
- public static String getOGNLExpression(Element element) {
+ public static String getOGNLExpression(Element element, String nameSpace) {
StringBuffer ognlExpression = new StringBuffer();
Node parent = element.getParentNode();
boolean isInBody = false;
@@ -55,8 +77,7 @@
Element parentElement = (Element) parent;
String parentName = YADOMUtil.getName(parentElement);
- if (parentName.equalsIgnoreCase("body") &&
- parent.getNamespaceURI().equalsIgnoreCase("http://schemas.xmlsoap.org/soap/envelope/")) {
+ if (parentName.equalsIgnoreCase("body") && checkParentNameSpace( parent.getNamespaceURI(), nameSpace ) ) {
isInBody = true;
break;
}
@@ -95,6 +116,30 @@
return ognlToken;
}
+
+ /**
+ * Will try to match the argument parentNS to a enum of default SOAP namespaces.
+ * If no match is made for a default SOAP namespace, this method will try to match
+ * the argument namespace.
+ *
+ * @param parentNS
+ * @param namespace
+ * @return <code>true</code> if a namespace match has been made.
+ */
+ protected static boolean checkParentNameSpace( final String parentNS, String namespace )
+ {
+ if ( parentNS == null )
+ return false;
+
+ SOAPNameSpaces[] defaultNamespaces = SOAPNameSpaces.values();
+ for ( SOAPNameSpaces defaultNS : defaultNamespaces )
+ {
+ if ( parentNS.equalsIgnoreCase( defaultNS.getNameSpace() ))
+ return true;
+ }
+
+ return parentNS.equalsIgnoreCase( namespace );
+ }
private static boolean assertIsCollection(Element element) {
if(element.getAttributeNS(JBOSSESB_SOAP_NS, IS_COLLECTION_ATTRIB).equals("true")) {
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/soap/OGNLUtilsUnitTest.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -61,7 +61,24 @@
node = getNode("/soapenv:Envelope/soapenv:Body/cus:customerOrder/cus:items/cus:item[2]/cus:partNumber");
assertEquals("customerOrder.items[1].partNumber", OGNLUtils.getOGNLExpression((Element) node));
+
+ node = getNode("/soapenv:Envelope/soapenv:Body/cus:customerOrder/cus:items/cus:item[2]/cus:partNumber");
+ final String nameSpace = "http://schemas.xmlsoap.org/soap/envelope/";
+ assertEquals("customerOrder.items[1].partNumber", OGNLUtils.getOGNLExpression((Element) node, nameSpace));
}
+
+ public void test_checkParentNameSpace( )
+ {
+ final String parentNS = "http://schemas.xmlsoap.org/soap/envelope/";
+ boolean exists = OGNLUtils.checkParentNameSpace( parentNS, null );
+ assertTrue( exists );
+
+ final String customNS = "http://www.w3.org/2003/05/soap-envelope";
+ exists = OGNLUtils.checkParentNameSpace( parentNS, customNS );
+ assertTrue( exists );
+ exists = OGNLUtils.checkParentNameSpace( null, null );
+ assertFalse( exists );
+ }
private Node getNode(String xpath) throws IOException, SAXException, XPathExpressionException {
Document order = YADOMUtil.parseStream(getClass().getResourceAsStream("ognl-test-01.xml"), false, false, true);
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -214,6 +214,13 @@
*
* The value of the "smooksTransform" property is resolved by first checking it as a filesystem based resource.
* Failing that, it's checked as a classpath resource and failing that, as a URI based resource.
+ *
+ * <h3>Specifying a different SOAP schema</h3>
+ * <pre>
+ * <property name="SOAPNS" value="http://www.w3.org/2009/09/soap-envelope"/>
+ * </pre>
+ * This is an optional property and can be used to specify the SOAP schema that should be
+ * used by OGNL.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
@@ -222,6 +229,7 @@
private Logger logger = Logger.getLogger(SOAPClient.class);
private String wsdl;
private String soapAction;
+ private String soapNs;
private String paramsLocation;
private String responseLocation;
private boolean responseAsOgnlMap;
@@ -251,6 +259,7 @@
if(xstreamAliases != null && xstreamAliases.length != 0) {
configureXStreamDeserializer(xstreamAliases);
}
+ soapNs = config.getAttribute("SOAPNS");
// Extract the HttpClient creation properties from the ConfigTree. Thesee are passed
// to the HttpClientFacatory...
@@ -302,7 +311,7 @@
String request;
try {
- request = soapUIInvoker.buildRequest(wsdl, getEndpointOperation(), params, httpClientProps, smooksTransform);
+ request = soapUIInvoker.buildRequest(wsdl, getEndpointOperation(), params, httpClientProps, smooksTransform, soapNs);
} catch (IOException e) {
throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
} catch (SAXException e) {
@@ -315,6 +324,11 @@
return message;
}
+
+ public String getSoapNS()
+ {
+ return soapNs;
+ }
protected String getEndpointOperation() {
URI soapActionURI;
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -34,7 +34,7 @@
*/
public class SoapUIInvoker {
- private static final String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName()};
+ private static final String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName(), String.class.getName()};
private static final String[] getEndpointSig = new String[] {String.class.getName(), Properties.class.getName()};
private MBeanServer mbeanServer;
private ObjectName serviceName;
@@ -59,14 +59,17 @@
* @param smooksResource {@link org.milyn.Smooks} transformation configuration resource file.
* Null if no transformations are to be performed on the SOAP message before serializing it
* for return.
+ * @param soapNs the SOAP namespace. If null one of the defaults will be used:
+ * http://schemas.xmlsoap.org/soap/envelope/
+ * http://www.w3.org/2003/05/soap-envelope
* @return The SOAP Message.
* @throws java.io.IOException Failed to load WSDL.
* @throws UnsupportedOperationException Operation not supported on specified WSDL.
* @throws org.xml.sax.SAXException Failed to parse the SOAP UI generated request message.
*/
- public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource) throws IOException, UnsupportedOperationException, SAXException {
+ public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
try {
- return (String) mbeanServer.invoke(serviceName, "buildRequest", new Object[] {wsdl, operation, params, httpClientProps, smooksResource}, buildRequestSig);
+ return (String) mbeanServer.invoke(serviceName, "buildRequest", new Object[] {wsdl, operation, params, httpClientProps, smooksResource, soapNs}, buildRequestSig);
} catch (InstanceNotFoundException e) {
throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
} catch (MBeanException e) {
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -94,6 +94,14 @@
SOAPClient soapClient = new SOAPClient(actionConfig);
assertEquals("SendSalesOrderNotification", soapClient.getEndpointOperation());
}
+
+ public void test_soapSetSOAPNameSpace() throws ConfigurationException, ActionProcessingException {
+ String expectedSOAPNS = "http://www.w3.org/2003/05/soap-envelope";
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-07");
+ actionConfig.setAttribute( "SOAPNS", expectedSOAPNS );
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ assertEquals( expectedSOAPNS, soapClient.getSoapNS());
+ }
private static String response_01 =
Modified: labs/jbossesb/trunk/product/services/soapui-client/build.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/build.xml 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soapui-client/build.xml 2007-08-02 14:16:43 UTC (rev 13965)
@@ -54,6 +54,7 @@
<mkdir dir="${sar.dir}" />
<copy todir="${sar.dir}">
<fileset dir="src" includes="lib/*.jar" excludes="lib/jboss-*.jar" />
+ <fileset dir="src" includes="lib/jboss-common.jar" />
<fileset dir="src/main/resources" />
<fileset dir="../../build/jbossesb/lib" includes="jbossesb-rosetta.jar" />
<fileset dir="../smooks/lib/ext" includes="milyn-*.jar" />
Added: labs/jbossesb/trunk/product/services/soapui-client/src/lib/jboss-common.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/lib/jboss-common.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/lib/xbean-2.2.0.jar
===================================================================
(Binary files differ)
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-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -95,14 +95,15 @@
* Smooks resource configuration XML, not a file name.
* Null if no transformations are to be performed on the SOAP message before serializing it
* for return.
+ * @param soapNs optional SOAP namespace
* @return The SOAP Message.
* @throws IOException Failed to load WSDL.
*/
- public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource) throws IOException, UnsupportedOperationException, SAXException {
+ public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
Operation operationInst = getOperation(wsdl, operation, httpClientProps);
String requestTemplate = operationInst.getRequestAt(0).getRequestContent();
- return buildRequest(requestTemplate, params, smooksResource);
+ return buildRequest(requestTemplate, params, smooksResource, soapNs);
}
/**
@@ -154,13 +155,13 @@
return new EsbWsdlLoader(wsdl, httpClient);
}
- private String buildRequest(String soapMessage, Map params, String smooksResource) throws IOException, SAXException {
+ private String buildRequest(String soapMessage, Map params, String smooksResource, String soapNs) throws IOException, SAXException {
Document messageDoc = docBuilder.parse(new ByteArrayInputStream(soapMessage.getBytes()));
Element docRoot = messageDoc.getDocumentElement();
expandMessage(docRoot, params);
- injectParameters(docRoot, params);
+ injectParameters(docRoot, params, soapNs);
if(smooksResource != null) {
applySmooksTransform(smooksResource, messageDoc);
}
@@ -281,7 +282,7 @@
}
}
- private void injectParameters(Element element, Map params) {
+ private void injectParameters(Element element, Map params, String soapNs) {
NodeList children = element.getChildNodes();
int childCount = children.getLength();
@@ -290,7 +291,7 @@
if (childCount == 1 && node.getNodeType() == Node.TEXT_NODE) {
if (node.getTextContent().equals("?")) {
- String ognl = OGNLUtils.getOGNLExpression(element);
+ String ognl = OGNLUtils.getOGNLExpression(element, soapNs);
Object param;
param = OGNLUtils.getParameter(ognl, params);
@@ -299,7 +300,7 @@
element.appendChild(element.getOwnerDocument().createTextNode(param.toString()));
}
} else if (node.getNodeType() == Node.ELEMENT_NODE) {
- injectParameters((Element) node, params);
+ injectParameters((Element) node, params, soapNs);
}
}
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-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -46,12 +46,13 @@
* @param smooksResource {@link org.milyn.Smooks} transformation configuration resource file.
* Null if no transformations are to be performed on the SOAP message before serializing it
* for return.
+ * @param soapNs optional SOAP namespace
* @return The SOAP Message.
* @throws IOException Failed to load WSDL.
* @throws UnsupportedOperationException Operation not supported on specified WSDL.
* @throws SAXException Failed to parse the SOAP UI generated request message.
*/
- public abstract String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource) throws IOException, UnsupportedOperationException, SAXException;
+ public abstract String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException;
/**
* Get the 1st endpoint from the specified WSDL.
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2007-08-02 14:15:45 UTC (rev 13964)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2007-08-02 14:16:43 UTC (rev 13965)
@@ -59,13 +59,14 @@
properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
params.put("salesOrderNotification", new OrderNotification());
- String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params, properties, null);
+ String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params, properties, null, null);
assertTrue("Generated SOAP message not as expected. See expected_01.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_01.xml"), new ByteArrayInputStream(message.getBytes())));
assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), properties));
}
public void test_has_collections() throws IOException, SAXException, ConfigurationException {
File wsdlFile = new File(WSDL_LOCATAION + "/BPELRetailer.wsdl");
+ String soapNs = null;
SoapUIClientService mbean = new SoapUIClientService();
Map params = new HashMap();
CustomerOrder1 order1 = new CustomerOrder1();
@@ -81,21 +82,21 @@
order2.items = items2;
params.put("customerOrder", order1);
- String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
+ String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null, soapNs);
assertTrue("Generated SOAP message not as expected. See expected_02.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_02.xml"), new ByteArrayInputStream(message.getBytes())));
items1.remove(0);items1.remove(0);items1.remove(0);
- message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
+ message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null, soapNs);
assertTrue("Generated SOAP message not as expected. See expected_03.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_03.xml"), new ByteArrayInputStream(message.getBytes())));
params.put("customerOrder", order2);
- message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
+ message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null, soapNs);
assertTrue("Generated SOAP message not as expected. See expected_02.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_02.xml"), new ByteArrayInputStream(message.getBytes())));
items2 = new OrderItem[] {new OrderItem(4, "item4", 4, new BigDecimal(4.00), 4)};
order2.items = items2;
params.put("customerOrder", order2);
- message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
+ message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null, soapNs);
assertTrue("Generated SOAP message not as expected. See expected_03.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_03.xml"), new ByteArrayInputStream(message.getBytes())));
}
@@ -106,7 +107,7 @@
properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
params.put("salesOrderNotification", new OrderNotification());
- String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params, properties, StreamUtils.readStreamString(getClass().getResourceAsStream("sendNotificationTransform.xml"), "UTF-8"));
+ String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params, properties, StreamUtils.readStreamString(getClass().getResourceAsStream("sendNotificationTransform.xml"), "UTF-8"), null);
assertTrue("Generated SOAP message not as expected. See expected_04.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_04.xml"), new ByteArrayInputStream(message.getBytes())));
assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), properties));
}
More information about the jboss-svn-commits
mailing list