[jboss-svn-commits] JBL Code SVN: r32699 - 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 May 1 05:11:41 EDT 2010
Author: mageshbk at jboss.com
Date: 2010-05-01 05:11:40 -0400 (Sat, 01 May 2010)
New Revision: 32699
Added:
labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/helloworld_soap1.2.wsdl
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/SoapUIClientServiceMBeanUnitTest.java
Log:
[JBESB-3102] - Added facility to switch ContentType in SOAPClient based on SOAP version
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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -155,6 +155,32 @@
}
}
+ /**
+ * Get the Content Type for the appropriate SOAP version of the 1st interface from the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @return The operation endpoint URL.
+ * @throws IOException Failed to load WSDL.
+ */
+ public String getContentType(String wsdl, Properties httpClientProps) throws IOException {
+ try {
+ return (String) mbeanServer.invoke(serviceName, "getSOAPVersion", new Object[] {wsdl, 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) {
+ if(e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ throw new RuntimeException(e);
+ } catch (ReflectionException e) {
+ if(e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ throw new RuntimeException(e);
+ }
+ }
+
private void rethrowException(Throwable e) throws IOException, UnsupportedOperationException, SAXException {
Throwable cause = e.getCause();
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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -292,7 +292,9 @@
private Properties httpClientProps = new Properties();
private HttpClient httpclient;
private HostConfiguration hostconfig;
+ private String endpoint;
private String endpointUrl;
+ private String contentType;
private MessagePayloadProxy payloadProxy;
private boolean httpResponseStatusEnabled;
@@ -328,7 +330,7 @@
httpclient.setHostConfiguration(new HostConfiguration());
endpointUrl = config.getAttribute("endpointUrl");
-
+
httpResponseStatusEnabled = ResponseStatus.isHttpEnabled(config);
}
@@ -357,8 +359,23 @@
super.initialise();
// Create the SoapUIInvoker instance for this SOAPClient...
soapUIInvoker = new MBeanSoapUIInvoker();
+ createEndpoint();
}
+ public void createEndpoint() throws ActionLifecycleException {
+ try {
+ if(endpointUrl != null) {
+ endpoint = endpointUrl;
+ } else {
+ endpoint = soapUIInvoker.getEndpoint(wsdl, httpClientProps);
+ }
+ contentType = soapUIInvoker.getContentType(wsdl, httpClientProps) + ";charset=UTF-8";
+
+ } catch (IOException e) {
+ throw new ActionLifecycleException("soapUI Client Service invocation failed.", e);
+ }
+ }
+
public SoapUIInvoker getSoapUIInvoker() {
return soapUIInvoker;
}
@@ -482,21 +499,9 @@
}
private Response invokeEndpoint(String request) throws ActionProcessingException {
- String endpoint;
-
- try {
- if(endpointUrl != null) {
- endpoint = endpointUrl;
- } else {
- endpoint = soapUIInvoker.getEndpoint(wsdl, httpClientProps);
- }
-
- } catch (IOException e) {
- throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
- }
PostMethod post = new PostMethod(endpoint);
- post.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");
+ post.setRequestHeader("Content-Type", contentType);
post.setRequestHeader("SOAPAction", "\"" + soapAction + "\""); /// Customization to add quotes to Soap action
post.setRequestEntity(new StringRequestEntity(request));
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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -17,4 +17,6 @@
String buildFault(String wsdl, String operation, String faultName, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException;
String getEndpoint(String wsdl, Properties httpClientProps) throws IOException;
+
+ String getContentType(String wsdl, 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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -62,9 +62,14 @@
public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
return service.getEndpoint(wsdl, httpClientProps);
}
+
+ public String getContentType(String wsdl, Properties httpClientProps) throws IOException {
+ return service.getContentType(wsdl, httpClientProps);
+ }
};
setSoapUIInvoker(soapUIInvoker);
+ createEndpoint();
} catch (ConfigurationException e) {
throw new ActionLifecycleException("Failed to initialize SoapUIInvoker.", e);
}
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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -403,6 +403,20 @@
return wsdlInterfaces[0].getEndpoints()[0];
}
+ /**
+ * Get the Content Type for the appropriate SOAP version of the 1st interface from the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @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();
+ }
+
private WsdlInterface[] getWsdlInterfaces(String wsdl, Properties httpClientProps) throws IOException {
try {
WsdlInterface[] wsdlInterfaces = wsdls.get(wsdl);
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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -85,6 +85,16 @@
public abstract String getEndpoint(String wsdl, Properties httpClientProps) throws IOException;
/**
+ * Get the Content Type for the appropriate SOAP version of the 1st interface from the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @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;
+
+ /**
* Get the property file.
* @return The name of the property file being used.
*/
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-05-01 06:17:45 UTC (rev 32698)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2010-05-01 09:11:40 UTC (rev 32699)
@@ -350,6 +350,17 @@
assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), properties));
}
+ public void test_ContentTypes() throws Exception {
+ File 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);
+ assertEquals("ContentType mismatch for SOAP 1.1", "text/xml", str);
+ 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);
+ assertEquals("ContentType mismatch for SOAP 1.2", "application/soap+xml", str);
+ }
private void addOrderItems(List<OrderItem> items) {
Added: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/helloworld_soap1.2.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/helloworld_soap1.2.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/helloworld_soap1.2.wsdl 2010-05-01 09:11:40 UTC (rev 32699)
@@ -0,0 +1,71 @@
+<wsdl:definitions targetNamespace='http://soa.jboss.org/ESBServiceSample' xmlns:ns1='http://www.jboss.org/sayHi' xmlns:ns2='http://www.jboss.org/sayHi' xmlns:ns3='http://www.jboss.org/sayHi' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap12/' xmlns:tns='http://soa.jboss.org/ESBServiceSample' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
+ <wsdl:types>
+ <xs:schema elementFormDefault='qualified' targetNamespace='http://www.jboss.org/sayHi' version='1.0' xmlns:x1='http://www.jboss.org/sayHi' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='sayHi' type='x1:sayHi'/>
+ <xs:complexType name='sayHi'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='arg0' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+
+ </xs:schema>
+ <xs:schema elementFormDefault='qualified' targetNamespace='http://www.jboss.org/sayHi' version='1.0' xmlns:x1='http://www.jboss.org/sayHi' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='sayHiReponse' type='x1:sayHiReponse'/>
+ <xs:complexType name='sayHiReponse'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='arg0' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+
+ <xs:schema elementFormDefault='qualified' targetNamespace='http://www.jboss.org/sayHi' version='1.0' xmlns:x1='http://www.jboss.org/sayHi' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='sayFault' type='x1:fault'/>
+ <xs:complexType name='fault'>
+ <xs:sequence>
+ <xs:element name='code' type='xs:string'/>
+ <xs:element name='faultString' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+
+ </wsdl:types>
+ <wsdl:message name='HelloWorldPubServiceReq'>
+ <wsdl:part element='ns1:sayHi' name='in'></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name='HelloWorldPubServiceRes'>
+ <wsdl:part element='ns1:sayHiReponse' name='out'></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name='HelloWorldPubServiceFault1'>
+ <wsdl:part element='ns1:sayFault' name='fault1'></wsdl:part>
+
+ </wsdl:message>
+ <wsdl:portType name='HelloWorldPubServicePortType'>
+ <wsdl:operation name='HelloWorldPubServiceOp'>
+ <wsdl:input message='tns:HelloWorldPubServiceReq' name='HelloWorldPubServiceReq'></wsdl:input>
+ <wsdl:output message='tns:HelloWorldPubServiceRes' name='HelloWorldPubServiceRes'></wsdl:output>
+ <wsdl:fault message='tns:HelloWorldPubServiceFault1' name='HelloWorldPubServiceFault1'></wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name='HelloWorldPubServiceBinding' type='tns:HelloWorldPubServicePortType'>
+
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <wsdl:operation name='HelloWorldPubServiceOp'>
+ <wsdl:input>
+ <soap:body use='literal'/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use='literal'/>
+ </wsdl:output>
+ <wsdl:fault name='HelloWorldPubServiceFault1'>
+
+ <soap:fault name='HelloWorldPubServiceFault1' use='literal'/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name='HelloWorldPubServiceService'>
+ <wsdl:port binding='tns:HelloWorldPubServiceBinding' name='HelloWorldPubServicePortType'>
+ <soap:address location='http://127.0.0.1:8080/Quickstart_helloworld_pub_service/ESBServiceSample/HelloWorldPubService'/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list