[jboss-svn-commits] JBL Code SVN: r33363 - in labs/jbossesb/trunk/product/services: soap/src/test/java/org/jboss/soa/esb/actions/soap/request and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jun 5 03:43:35 EDT 2010
Author: tfennelly
Date: 2010-06-05 03:43:34 -0400 (Sat, 05 Jun 2010)
New Revision: 33363
Modified:
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.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/request/MockSOAPClient.java
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/Customer.wsdl
labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
Log:
https://jira.jboss.org/browse/JBESB-3259
Add support for multiple wsdl services to SoapUIClientService
Fixed for getContent and getEndpoint.
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -35,8 +35,10 @@
public class MBeanSoapUIInvoker implements SoapUIInvoker {
private static final String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName(), String.class.getName()};
+ private static final String[] buildResponseSig = new String[] {String.class.getName(), String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName(), String.class.getName()};
private static final String[] buildFaultSig = new String[] {String.class.getName(), String.class.getName(), 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 static final String[] getEndpointSig = new String[] {String.class.getName(), String.class.getName(), Properties.class.getName()};
+ private static final String[] getContentTypeSig = new String[] {String.class.getName(), String.class.getName(), Properties.class.getName()};
private MBeanServer mbeanServer;
private ObjectName serviceName;
@@ -102,7 +104,7 @@
*/
public String buildResponse(String wsdl, String operation, String wServiceName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
try {
- return (String) mbeanServer.invoke(serviceName, "buildResponse", new Object[] {wsdl, operation, wServiceName, params, httpClientProps, smooksResource, soapNs}, buildRequestSig);
+ return (String) mbeanServer.invoke(serviceName, "buildResponse", new Object[] {wsdl, operation, wServiceName, params, httpClientProps, smooksResource, soapNs}, buildResponseSig);
} 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) {
@@ -137,9 +139,9 @@
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
+ public String getEndpoint(String wsdl, String wServiceName, Properties httpClientProps) throws IOException {
try {
- return (String) mbeanServer.invoke(serviceName, "getEndpoint", new Object[] {wsdl, httpClientProps}, getEndpointSig);
+ return (String) mbeanServer.invoke(serviceName, "getEndpoint", new Object[] {wsdl, wServiceName, httpClientProps}, getEndpointSig);
} 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) {
@@ -163,9 +165,9 @@
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public String getContentType(String wsdl, Properties httpClientProps) throws IOException {
+ public String getContentType(String wsdl, String wServiceName, Properties httpClientProps) throws IOException {
try {
- return (String) mbeanServer.invoke(serviceName, "getContentType", new Object[] {wsdl, httpClientProps}, getEndpointSig);
+ return (String) mbeanServer.invoke(serviceName, "getContentType", new Object[] {wsdl, wServiceName, httpClientProps}, getContentTypeSig);
} 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/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 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -493,9 +493,9 @@
if(endpointUrl != null) {
endpoint = endpointUrl;
} else {
- endpoint = soapUIInvoker.getEndpoint(wsdl, httpClientProps);
+ endpoint = soapUIInvoker.getEndpoint(wsdl, soapServiceName, httpClientProps);
}
- contentType = soapUIInvoker.getContentType(wsdl, httpClientProps) + ";charset=UTF-8";
+ contentType = soapUIInvoker.getContentType(wsdl, soapServiceName, httpClientProps) + ";charset=UTF-8";
} catch (IOException e) {
throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
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 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -16,7 +16,7 @@
String buildFault(String wsdl, String operation, String serviceName, String faultName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException;
- String getEndpoint(String wsdl, Properties httpClientProps) throws IOException;
+ String getEndpoint(String wsdl, String serviceName, Properties httpClientProps) throws IOException;
- String getContentType(String wsdl, Properties httpClientProps) throws IOException;
+ String getContentType(String wsdl, String serviceName, Properties httpClientProps) throws IOException;
}
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -59,12 +59,12 @@
return service.buildFault(wsdl, operation, null, faultName, params, httpClientProps, smooksResource, soapNs) ;
}
- public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
- return service.getEndpoint(wsdl, httpClientProps);
+ public String getEndpoint(String wsdl, String serviceName, Properties httpClientProps) throws IOException {
+ return service.getEndpoint(wsdl, serviceName, httpClientProps);
}
- public String getContentType(String wsdl, Properties httpClientProps) throws IOException {
- return service.getContentType(wsdl, httpClientProps);
+ public String getContentType(String wsdl, String serviceName, Properties httpClientProps) throws IOException {
+ return service.getContentType(wsdl, serviceName, httpClientProps);
}
};
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 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -403,10 +403,14 @@
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
-
- return wsdlInterfaces[0].getEndpoints()[0];
+ public String getEndpoint(String wsdl, String serviceName, Properties httpClientProps) throws IOException {
+ if(serviceName != null) {
+ WsdlInterface wsdlInterface = getServiceInterface(wsdl, serviceName, httpClientProps, true, true);
+ return wsdlInterface.getEndpoints()[0];
+ } else {
+ WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
+ return wsdlInterfaces[0].getEndpoints()[0];
+ }
}
/**
@@ -417,10 +421,14 @@
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public String getContentType(String wsdl, Properties httpClientProps) throws IOException {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
-
- return wsdlInterfaces[0].getSoapVersion().getContentType();
+ public String getContentType(String wsdl, String serviceName, Properties httpClientProps) throws IOException {
+ if(serviceName != null) {
+ WsdlInterface wsdlInterface = getServiceInterface(wsdl, serviceName, httpClientProps, true, true);
+ return wsdlInterface.getSoapVersion().getContentType();
+ } else {
+ WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
+ return wsdlInterfaces[0].getSoapVersion().getContentType();
+ }
}
private WsdlInterface[] getWsdlInterfaces(String wsdl, Properties httpClientProps) throws IOException {
@@ -484,7 +492,73 @@
throw new UnsupportedOperationException("Operation '" + operationName + "' not supported by WSDL '" + wsdl + "'.");
}
+
+ private WsdlInterface getServiceInterface(String wsdl, String serviceName, Properties httpClientProps, boolean refresh, boolean fail) throws IOException {
+ WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
+
+ for (WsdlInterface wsdlInterface : wsdlInterfaces) {
+ Definition definition;
+ try {
+ definition = wsdlInterface.getWsdlContext().getDefinition();
+ } catch (Exception e) {
+ IOException ioException = new IOException("Failed to get WsdlContext from WsdlInterface.");
+ ioException.initCause(e);
+ throw ioException;
+ }
+ if(hasService(serviceName, definition)) {
+ return wsdlInterface;
+ }
+
+ // Is it one of the imports...
+ Map imports = definition.getImports();
+ if(imports != null && !imports.isEmpty()) {
+ for(Object importListObj : imports.values()) {
+ if(importListObj instanceof List) {
+ List<Import> importList = (List<Import>) importListObj;
+ if(importList != null) {
+ for(Import importInst : importList) {
+ WsdlInterface importedInterface = getServiceInterface(importInst.getDefinition().getDocumentBaseURI(), serviceName, httpClientProps, true, false);
+ if(importedInterface != null) {
+ return importedInterface;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(refresh) {
+ // Try clearing WSDL cache, WSDL may have updated
+ wsdls.remove(wsdl);
+ wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
+
+ return getServiceInterface(wsdl, serviceName, httpClientProps, false, fail);
+ }
+
+ if(fail) {
+ throw new UnsupportedOperationException("Service by name '" + serviceName + "' not found on WSDL '" + wsdl + "'.");
+ }
+
+ return null;
+ }
+ private boolean hasService(String serviceName, Definition definition) {
+
+ Map<Object, Service> services = definition.getServices();
+
+ // Is it one of the services on this wsdl...
+ if(services != null && !services.isEmpty()) {
+ for(Service service : services.values()) {
+ if(serviceName.equals(service.getQName().toString())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
private QName getServiceName(QName bindingQName, Definition definition) {
try {
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 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -77,24 +77,26 @@
public abstract String buildFault(String wsdl, String operation, String serviceName, String faultName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException;
/**
- * Get the 1st endpoint from the specified WSDL.
+ * Get the named endpoint from the specified WSDL.
*
* @param wsdl WSDL URL.
+ * @param serviceName Service Name.
* @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public abstract String getEndpoint(String wsdl, Properties httpClientProps) throws IOException;
+ public abstract String getEndpoint(String wsdl, String serviceName, Properties httpClientProps) throws IOException;
/**
- * Get the Content Type for the appropriate SOAP version of the 1st interface from the specified WSDL.
+ * Get the Content Type for the appropriate SOAP version interface (for the named service) from the specified WSDL.
*
* @param wsdl WSDL URL.
+ * @param serviceName Service Name.
* @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public abstract String getContentType(String wsdl, Properties httpClientProps) throws IOException;
+ public abstract String getContentType(String wsdl, String serviceName, Properties httpClientProps) throws IOException;
/**
* Get the property file.
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/Customer.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/Customer.wsdl 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/Customer.wsdl 2010-06-05 07:43:34 UTC (rev 33363)
@@ -4,7 +4,7 @@
xmlns:tns="http://docs.active-endpoints.com/activebpel/sample/wsdl/customer/2006/04/Customer.wsdl"
xmlns:cust="http://schemas.active-endpoints.com/sample/customer/2006/04/Customer.xsd"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
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 2010-06-05 05:32:51 UTC (rev 33362)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2010-06-05 07:43:34 UTC (rev 33363)
@@ -66,7 +66,7 @@
params.put("salesOrderNotification", new OrderNotification());
String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", null, 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));
+ assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), null, properties));
}
public void test_has_collections_01() throws IOException, SAXException, ConfigurationException {
@@ -370,7 +370,7 @@
params.put("salesOrderNotification", new OrderNotification());
String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", null, 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));
+ assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), null, properties));
}
public void test_BuildResponse() throws Exception {
@@ -408,21 +408,51 @@
String message = mbean.buildRequest(wsdlFile.toURI().toString(), "CancelOrder", null, params, properties, null, null);
assertTrue("Generated SOAP message not as expected. See expected_05.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_05.xml"), new ByteArrayInputStream(message.getBytes())));
- assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), properties));
+ assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), null, properties));
}
+
+ public void test_getEndpoint() throws IOException, SAXException, ConfigurationException {
+ File wsdlFile = new File(WSDL_LOCATAION + "/BPELRetailer.wsdl");
+
+ properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+
+ SoapUIClientService mbean = new SoapUIClientService();
+ String endpoint = mbean.getEndpoint(wsdlFile.toURL().toString(), "{http://docs.active-endpoints.com/activebpel/sample/wsdl/customer/2006/04/Customer.wsdl}CustomerService", properties);
+ assertEquals("http://localhost:18080/active-bpel/services/ABI_Customer", endpoint);
+
+ endpoint = mbean.getEndpoint(wsdlFile.toURL().toString(), "{http://docs.active-endpoints.com/activebpel/sample/wsdl/retailer/2006/04/Retailer.wsdl}RetailerService", properties);
+ assertEquals("http://localhost:18080/active-bpel/services/Retailer", endpoint);
+ }
+
public void test_ContentTypes() throws Exception {
- File wsdlFile = new File(WSDL_LOCATAION + "/helloworld.wsdl");
+ SoapUIClientService mbean = new SoapUIClientService();
+ File wsdlFile;
+
+ wsdlFile = new File(WSDL_LOCATAION + "/helloworld.wsdl");
properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
- SoapUIClientService mbean = new SoapUIClientService();
- String str = mbean.getContentType(wsdlFile.toURL().toString(), properties);
+ String str = mbean.getContentType(wsdlFile.toURL().toString(), null, properties);
assertEquals("ContentType mismatch for SOAP 1.1", "text/xml", str);
- wsdlFile = new File(WSDL_LOCATAION + "/helloworld_soap1.2.wsdl");
+
+ wsdlFile = new File(WSDL_LOCATAION + "/helloworld_soap1.2.wsdl");
properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
- str = mbean.getContentType(wsdlFile.toURL().toString(), properties);
+ str = mbean.getContentType(wsdlFile.toURL().toString(), null, properties);
assertEquals("ContentType mismatch for SOAP 1.2", "application/soap+xml", str);
}
+ public void test_ContentTypes_for_serviceName() throws Exception {
+ File wsdlFile = new File(WSDL_LOCATAION + "/BPELRetailer.wsdl");
+
+ properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+
+ SoapUIClientService mbean = new SoapUIClientService();
+
+ String str = mbean.getContentType(wsdlFile.toURL().toString(), "{http://docs.active-endpoints.com/activebpel/sample/wsdl/customer/2006/04/Customer.wsdl}CustomerService", properties);
+ assertEquals("ContentType mismatch for SOAP 1.2", "application/soap+xml", str);
+
+ str = mbean.getContentType(wsdlFile.toURL().toString(), "{http://docs.active-endpoints.com/activebpel/sample/wsdl/retailer/2006/04/Retailer.wsdl}RetailerService", properties);
+ assertEquals("ContentType mismatch for SOAP 1.1", "text/xml", str);
+ }
private void addOrderItems(List<OrderItem> items) {
items.add(new OrderItem(1, "item1", 1, new BigDecimal(1.00), 1));
More information about the jboss-svn-commits
mailing list