[jboss-svn-commits] JBL Code SVN: r38426 - in labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src: test/java/org/jboss/soa/esb/actions/soap and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 15 12:49:19 EDT 2013
Author: tcunning
Date: 2013-10-15 12:49:18 -0400 (Tue, 15 Oct 2013)
New Revision: 38426
Added:
labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/RetailerCallback.wsdl
Modified:
labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java
labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
Log:
JBESB-3955
Commit Tadayoshi's fix for HttpClient properties if wsdl is a local file.
Modified: labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2013-10-15 09:43:56 UTC (rev 38425)
+++ labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2013-10-15 16:49:18 UTC (rev 38426)
@@ -29,6 +29,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
@@ -41,11 +42,11 @@
import javax.xml.stream.XMLStreamException;
import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.publish.Publish;
import org.jboss.internal.soa.esb.soap.OGNLUtils;
@@ -67,6 +68,7 @@
import org.jboss.soa.esb.message.ResponseStatus;
import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.util.XPathUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -329,13 +331,13 @@
}
soapNs = config.getAttribute("SOAPNS");
+ endpointUrl = config.getAttribute("endpointUrl");
+
// Extract the HttpClient creation properties from the ConfigTree. These are passed
// to the HttpClientFacatory...
extractHttpClientProps(config);
httpclient = HttpClientFactory.createHttpClient(httpClientProps);
- endpointUrl = config.getAttribute("endpointUrl");
-
httpResponseStatusEnabled = ResponseStatus.isHttpEnabled(config);
}
@@ -382,10 +384,22 @@
super.destroy();
}
- private void extractHttpClientProps(ConfigTree config) {
+ private void extractHttpClientProps(ConfigTree config) throws ConfigurationException {
ConfigTree[] httpClientConfigTrees = config.getChildren(HttpClientFactory.HTTP_CLIENT_PROPERTY);
- httpClientProps.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdl);
+ // JBESB-3947
+ String targetHostUrl = endpointUrl != null ? endpointUrl : wsdl;
+ if (targetHostUrl.startsWith("file:")) {
+ try {
+ String wsdlContent = IOUtils.toString(new URL(wsdl).openStream());
+ Element address = XPathUtil.getNodeFromXPathExpression(wsdlContent, "/definitions/service/port/address");
+ targetHostUrl = address.getAttribute("location");
+ } catch (Exception e) {
+ throw new ConfigurationException("Failed to read endpoint URL from WSDL: " + wsdl, e);
+ }
+ }
+
+ httpClientProps.setProperty(HttpClientFactory.TARGET_HOST_URL, targetHostUrl);
final ConfigTree parent = config.getParent();
if (parent != null) {
final String maxThreads = parent.getAttribute(ListenerTagNames.MAX_THREADS_TAG);
@@ -726,4 +740,8 @@
}
}
}
+
+ protected HttpClient getHttpClient() {
+ return httpclient;
+ }
}
Added: labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/RetailerCallback.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/RetailerCallback.wsdl (rev 0)
+++ labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/RetailerCallback.wsdl 2013-10-15 16:49:18 UTC (rev 38426)
@@ -0,0 +1,303 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions name="OrderManagerPortTypeService" targetNamespace="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"
+ xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://ordermanagement.activebpel.com/jaws"
+ xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"
+ xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <types>
+
+ <schema elementFormDefault="qualified" targetNamespace="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"
+ xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://ordermanagement.activebpel.com/jaws"
+ xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:tns="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <import namespace="http://ordermanagement.activebpel.com/jaws"/>
+
+ <complexType name="CancelOrder">
+
+ <sequence>
+
+ <element name="orderInquiry" nillable="true" type="ns2:OrderInquiry"/>
+
+ </sequence>
+
+ </complexType>
+
+ <complexType name="CustomerOrder">
+
+ <sequence>
+
+ <element name="header" nillable="true" type="ns2:OrderHeader"/>
+
+ <element maxOccurs="unbounded" minOccurs="0" name="items" nillable="true" type="ns2:Item"/>
+
+ </sequence>
+
+ </complexType>
+
+ <complexType name="SalesOrderFault">
+
+ <sequence>
+
+ <element name="reason" nillable="true" type="string"/>
+
+ </sequence>
+
+ </complexType>
+
+
+ <complexType name="SalesOrderNotification">
+
+ <sequence>
+
+ <element ref="tns:orderNumber"/>
+
+ </sequence>
+
+ </complexType>
+
+
+ <element name="cancelOrder" type="tns:CancelOrder"/>
+
+ <element name="cancelOrderResponse" type="boolean"/>
+
+ <element name="customerOrder" type="tns:CustomerOrder"/>
+
+ <element name="SalesOrderFault" type="tns:SalesOrderFault"/>
+
+ <element name="customerOrderResponse" type="string"/>
+
+ <element name="salesOrderNotification" type="tns:SalesOrderNotification"/>
+
+ <element name="salesOrderNotificationAck" type="boolean"/>
+
+ <element name="orderNumber" type="string"/>
+
+ <element name="CancelOrder">
+ <complexType>
+ <sequence>
+ <element name="in" type="string"></element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="out" type="string"></element>
+
+ </schema>
+
+ <schema elementFormDefault="qualified" targetNamespace="http://ordermanagement.activebpel.com/jaws"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns1="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"
+ xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:tns="http://ordermanagement.activebpel.com/jaws"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <import namespace="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"/>
+
+ <complexType name="Address">
+
+ <sequence>
+
+ <element name="city" nillable="true" type="string"/>
+
+ <element name="state" nillable="true" type="string"/>
+
+ <element name="street1" nillable="true" type="string"/>
+
+ <element name="street2" nillable="true" type="string"/>
+
+ <element name="zip" nillable="true" type="string"/>
+
+ </sequence>
+
+ </complexType>
+
+ <complexType name="Contact">
+
+ <sequence>
+
+ <element name="email" nillable="true" type="string"/>
+
+ <element name="fax" nillable="true" type="string"/>
+
+ <element name="name" nillable="true" type="string"/>
+
+ <element name="phone" nillable="true" type="string"/>
+
+ </sequence>
+
+ </complexType>
+
+ <complexType name="Item">
+
+ <sequence>
+
+ <element name="description" nillable="true" type="string"/>
+
+ <element name="extensionAmount" nillable="true" type="decimal"/>
+
+ <element name="partNumber" nillable="true" type="string"/>
+
+ <element name="price" nillable="true" type="decimal"/>
+
+ <element name="quantity" type="int"/>
+
+ </sequence>
+
+ </complexType>
+
+ <complexType name="OrderHeader">
+
+ <sequence>
+
+ <element name="billTerms" nillable="true" type="string"/>
+
+ <element name="billTo" nillable="true" type="tns:Party"/>
+
+ <element name="customerNumber" nillable="true" type="string"/>
+
+ <element name="orderDate" nillable="true" type="dateTime"/>
+
+ <element name="orderTotal" nillable="true" type="decimal"/>
+
+ <element name="poNumber" nillable="true" type="string"/>
+
+ <element name="shipTerms" nillable="true" type="string"/>
+
+ <element name="shipTo" nillable="true" type="tns:Party"/>
+
+ </sequence>
+
+ </complexType>
+
+ <complexType name="OrderInquiry">
+
+ <sequence>
+
+ <element name="customerNumber" nillable="true" type="string"/>
+
+ <element name="poNumber" nillable="true" type="string"/>
+
+ </sequence>
+ <attribute name="inquiryId" type="string"/>
+
+ </complexType>
+
+ <complexType name="Party">
+
+ <sequence>
+
+ <element name="address" nillable="true" type="tns:Address"/>
+
+ <element name="company" nillable="true" type="string"/>
+
+ <element name="contact" nillable="true" type="tns:Contact"/>
+
+ </sequence>
+
+ </complexType>
+
+ </schema>
+
+ </types>
+
+ <message name="SendSalesOrderNotificationResponse">
+
+ <part element="tns:salesOrderNotificationAck" name="Document"/>
+
+ </message>
+
+ <message name="SendSalesOrderNotificationRequest">
+
+ <part element="tns:salesOrderNotification" name="Document"/>
+
+ </message>
+
+<message name="CancelOrderRequest">
+
+ <part name="Document" element="tns:cancelOrder"></part>
+
+ </message>
+
+ <message name="CancelOrderResponse">
+
+ <part name="Document" element="tns:cancelOrderResponse"></part>
+
+ </message>
+
+
+ <portType name="RetailerCallbackPortType">
+
+ <operation name="SendSalesOrderNotification">
+
+ <input message="tns:SendSalesOrderNotificationRequest"/>
+
+ <output message="tns:SendSalesOrderNotificationResponse"/>
+
+ </operation>
+ <operation name="CancelOrder">
+ <input message="tns:CancelOrderRequest"></input>
+ <output message="tns:CancelOrderResponse"></output>
+ </operation>
+
+
+ </portType>
+
+ <binding name="RetailerCallbackBinding" type="tns:RetailerCallbackPortType">
+
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ <operation name="SendSalesOrderNotification">
+
+ <soap:operation soapAction="" style="document" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ <input>
+
+ <soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ </input>
+
+ <output>
+
+ <soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ </output>
+
+ </operation>
+
+ <operation name="CancelOrder">
+
+ <soap:operation soapAction="" style="document" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ <input>
+
+ <soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ </input>
+
+ <output>
+
+ <soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ </output>
+
+ </operation>
+
+ </binding>
+
+ <service name="RetailerCallback">
+
+ <port binding="tns:RetailerCallbackBinding" name="RetailerCallbackPort">
+
+ <soap:address location="http://localhost:18080/active-bpel/services/RetailerCallback"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
+
+ </port>
+
+ </service>
+
+</definitions>
+
Modified: labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java 2013-10-15 09:43:56 UTC (rev 38425)
+++ labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java 2013-10-15 16:49:18 UTC (rev 38426)
@@ -1,6 +1,7 @@
package org.jboss.soa.esb.actions.soap;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.util.Map;
@@ -8,6 +9,8 @@
import junit.framework.TestCase;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.io.FileUtils;
import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.internal.soa.esb.util.XMLHelper;
import org.jboss.soa.esb.ConfigurationException;
@@ -197,6 +200,22 @@
message, XMLHelper.compareXMLContent(getClass().getResourceAsStream(expected), new ByteArrayInputStream(response.getBytes())));
}
+ // JBESB-3947
+ public void test_localWsdl_httpProxy() throws ConfigurationException, ActionProcessingException, ParserConfigurationException, SAXException, IOException {
+ String wsdl = "RetailerCallback.wsdl";
+ File localWsdlFile = new File(System.getProperty("java.io.tmpdir"), wsdl);
+ FileUtils.copyURLToFile(getClass().getResource(wsdl), localWsdlFile);
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-10");
+ actionConfig.setAttribute("wsdl", localWsdlFile.toURI().toString());
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ HttpClient httpClient = soapClient.getHttpClient();
+
+ assertEquals("localhost", httpClient.getHostConfiguration().getHost());
+ assertEquals(18080, httpClient.getHostConfiguration().getPort());
+ assertEquals("myproxy", httpClient.getHostConfiguration().getProxyHost());
+ assertEquals(12345, httpClient.getHostConfiguration().getProxyPort());
+ }
+
private static Response response_01 = new Response(
"<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" +
Modified: labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml 2013-10-15 09:43:56 UTC (rev 38425)
+++ labs/jbossesb/branches/JBESB_4_11_CP2/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml 2013-10-15 16:49:18 UTC (rev 38426)
@@ -71,6 +71,13 @@
<property name="SOAPAction" value="ZZZ"/>
<property name="responseAsOgnlMap" value="false" />
</action>
+ <action name="soapui-client-action-10" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="file:///tmp/RetailerCallback.wsdl">
+ <http-client-property name="http.proxyHost" value="myproxy"/>
+ <http-client-property name="http.proxyPort" value="12345"/>
+ </property>
+ <property name="SOAPAction" value="ZZZ"/>
+ </action>
</actions>
</service>
More information about the jboss-svn-commits
mailing list