[jboss-svn-commits] JBL Code SVN: r27164 - in labs/jbossesb/workspace/dward/wsproxy/product: rosetta/src/org/jboss/internal/soa/esb/util and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jun 26 19:23:42 EDT 2009
Author: dward
Date: 2009-06-26 19:23:41 -0400 (Fri, 26 Jun 2009)
New Revision: 27164
Added:
labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/src/response.xsl
labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
Modified:
labs/jbossesb/workspace/dward/wsproxy/product/.classpath
labs/jbossesb/workspace/dward/wsproxy/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java
labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/jboss-esb.xml
labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/readme.txt
labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java
Log:
added transformation capabilities to SOAPProxy, added a utility method to StreamUtils, bolstered readme.txt, and fixed apparent bugs in AbstractWsdlContractPublisher
Modified: labs/jbossesb/workspace/dward/wsproxy/product/.classpath
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/.classpath 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/.classpath 2009-06-26 23:23:41 UTC (rev 27164)
@@ -21,6 +21,10 @@
<classpathentry excluding="**/.svn/" kind="src" path="services/jbpm/ant-task/test"/>
<classpathentry excluding="**/.svn/" kind="src" path="services/jbossesb/src/main/java"/>
<classpathentry excluding="**/.svn/" kind="src" path="services/jbossesb/src/test/java"/>
+ <classpathentry excluding="**/.svn/" kind="src" path="samples/quickstarts/webservice_wsproxy_basic/src"/>
+ <classpathentry excluding="**/.svn/" kind="src" path="samples/quickstarts/webservice_wsproxy_basic/war/src"/>
+ <classpathentry excluding="**/.svn/" kind="src" path="samples/quickstarts/webservice_wsproxy_routed/src"/>
+ <classpathentry excluding="**/.svn/" kind="src" path="samples/quickstarts/webservice_wsproxy_routed/war/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="etc/test/resources/log4j/dev"/>
<classpathentry kind="lib" path="build/jbossesb/lib/jbossesb-config-model-1.1.0.jar"/>
Modified: labs/jbossesb/workspace/dward/wsproxy/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java 2009-06-26 23:23:41 UTC (rev 27164)
@@ -104,10 +104,24 @@
}
}
}
+
+ public static byte[] getResourceAsBytes(String resource) throws ConfigurationException {
+ InputStream stream = getResource(resource);
+ try {
+ return readStream(stream);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ logger.error("Error closing resource stream '" + resource + "'.", e);
+ }
+ }
+ }
+
/**
* Load a stream resource.
- * @param resource Resource classpath/filesystem/URL location.
+ * @param resource Resource filesystem/classpath/URL location.
* @return The resource stream.
* @throws ConfigurationException Failed to load the resource.
*/
Modified: labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/jboss-esb.xml 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/jboss-esb.xml 2009-06-26 23:23:41 UTC (rev 27164)
@@ -38,6 +38,11 @@
<!--
<property name="endpointUrl" value="http://127.0.0.1:8888/Quickstart_webservice_wsproxy_basic/HelloWorldWS"/>
-->
+ <!-- xsl testing -->
+ <!--
+ <property name="request-xsl" value="..."/>
+ <property name="response-xsl" value="/response.xsl"/>
+ -->
</action>
<action name="echo-response"
class="org.jboss.soa.esb.actions.SystemPrintln"
Modified: labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/readme.txt
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/readme.txt 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/readme.txt 2009-06-26 23:23:41 UTC (rev 27164)
@@ -2,7 +2,6 @@
=========
This example demonstrates how to proxy a basic 181 Web Service via an ESB SOAPProxy action.
This ESB will make an RPC webservice request that requires a single "toWhom" string parameter.
-
Running this quickstart:
========================
@@ -21,26 +20,72 @@
3. Switch back to Application Server console to see the output from the ESB
4. In this folder ("Window1"), type 'ant undeploy'.
+ 'rundirect' target description:
+ - This simply calls the target JBossWS webservice directly.
+
+ 'runtest' target description:
+ - This will exercise the target webservice *via* the SOAPProxy.
+ - Running it will create output similar to this:
+
+[java] **** REQUEST URL: http://127.0.0.1:8765
+[java] **** REQUEST BODY: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://webservice_wsproxy_basic/helloworld"><soapenv:Header/><soapenv:Body><hel:sayHello><toWhom>dward</toWhom></hel:sayHello></soapenv:Body></soapenv:Envelope>
+[java] 18:10:10,664 DEBUG [main][header] >> "POST / HTTP/1.1[\r][\n]"
+[java] 18:10:10,699 DEBUG [main][header] >> "SOAPAction: ""[\r][\n]"
+[java] 18:10:10,699 DEBUG [main][header] >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]"
+[java] 18:10:10,700 DEBUG [main][header] >> "Host: 127.0.0.1:8765[\r][\n]"
+[java] 18:10:10,700 DEBUG [main][header] >> "Content-Length: 247[\r][\n]"
+[java] 18:10:10,700 DEBUG [main][header] >> "[\r][\n]"
+[java] 18:10:10,701 DEBUG [main][content] >> "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://webservice_wsproxy_basic/helloworld"><soapenv:Header/><soapenv:Body><hel:sayHello><toWhom>dward</toWhom></hel:sayHello></soapenv:Body></soapenv:Envelope>"
+[java] 18:10:10,829 DEBUG [main][header] << "HTTP/1.1 200 OK[\r][\n]"
+[java] 18:10:10,832 DEBUG [main][header] << "Server: Apache-Coyote/1.1[\r][\n]"
+[java] 18:10:10,832 DEBUG [main][header] << "Content-Type: text/xml[\r][\n]"
+[java] 18:10:10,832 DEBUG [main][header] << "Content-Length: 297[\r][\n]"
+[java] 18:10:10,832 DEBUG [main][header] << "Date: Fri, 26 Jun 2009 23:10:10 GMT[\r][\n]"
+[java] **** RESPONSE CODE: 200
+[java] 18:10:10,835 DEBUG [main][content] << "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:sayHelloResponse xmlns:ns2="http://webservice_wsproxy_basic/helloworld"><return>Hello 'dward' on Fri Jun 26 18:10:10 GMT-05:00 2009</return></ns2:sa"
+[java] 18:10:10,835 DEBUG [main][content] << "yHelloResponse></env:Body></env:Envelope>"
+[java] **** RESPONSE BODY: <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:sayHelloResponse xmlns:ns2="http://webservice_wsproxy_basic/helloworld"><return>Hello 'dward' on Fri Jun 26 18:10:10 GMT-05:00 2009</return></ns2:sayHelloResponse></env:Body></env:Envelope>
+
+ - If you want to test a response xsl transform, uncomment this line:
+ <property name="response-xsl" value="/response.xsl"/>
+ , and you will get output similar to this (notice <return> is now <transformedReturn>):
+
+[java] **** RESPONSE BODY: <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+[java] <env:Header/>
+[java] <env:Body>
+[java] <ns2:sayHelloResponse xmlns:ns2="http://webservice_wsproxy_basic/helloworld">
+[java] <transformedReturn>Hello 'dward' on Fri Jun 26 18:11:24 GMT-05:00 2009</transformedReturn>
+[java] </ns2:sayHelloResponse>
+[java] </env:Body>
+[java] </env:Envelope>
+
Project file descriptions:
==========================
jboss-esb.xml:
A JBoss Remoting Gateway Listener accepts the incoming HTTP call makes it available to the
- WSProxy_Basic/WSProxy service, who has a message exchange pattern of RequestResponse. In the action
- chain, there are 3 actions:
+ WSProxy_Basic/WSProxy service, who has a message exchange pattern of RequestResponse. In the
+ action chain, there are 3 actions:
1) echo out the incoming SOAP request,
2) use the SOAPProxy class to invoke the original webservice endpoint,
3) echo out the outgoing SOAP response.
- NOTE:
- Only a single property is needed for the SOAPProxy: the original "wsdl" (whose endpoint will get
- re-written and exposed as new wsdl from the ESB). Additionally, any HttpRouter properties can be
- applied to the SOAPProxy configuration, allowing it to override the SOAPProxy defaults when invoking
- an HTTP-based webservice endpoint.
+ Configuration:
+ - wsdl (required): The original wsdl url whose WS endpoint will get re-written and exposed as
+ new wsdl from the ESB. Depending upon the <definitions><service><port><soap:address location
+ attribute's protocol (for example "http"), a protocol-specific SOAPProxyTransport
+ implementation is used.
+ - request-xsl (optional): The filepath/classpath/url XSL which will transform the request
+ message payload (the SOAP Envelope) before the external endpoint is invoked.
+ - response-xsl (optional): The filepath/classpath/url XSL which will transform the response
+ message payload (the SOAP Envelope) after the external endpoint is invoked.
+ For other possible configuration properties, see the specific SOAPProxyTransport
+ implementations themselves.
log4j.xml:
Needed to configure log4J used by the quickstart.
src/../SendWSMessage.java:
- Sends a SOAP message to the target webservice endpoint (see "ant rundirect" and "ant runtest" below).
+ Sends a SOAP message to the target webservice endpoint (see "ant rundirect" and "ant runtest"
+ below).
org.jboss.soa.esb.actions.soap.proxy.SOAPProxy
This class is used to proxy the call to the original webservice.
@@ -48,10 +93,11 @@
build.xml:
Targets and structure description:
* the rundirect task calls the
- org.jboss.soa.esb.samples.quickstart.webservice_wsproxy_basic.test.SendWSMessage class and passes
- in and argument representing the *ORIGINAL* webservice endpoint and an argument representing the
- string-based message to invoke the webserivce with.
+ org.jboss.soa.esb.samples.quickstart.webservice_wsproxy_basic.test.SendWSMessage class and
+ passes in and argument representing the *ORIGINAL* webservice endpoint and an argument
+ representing the string-based message to invoke the webserivce with.
* the runtest task calls the
- org.jboss.soa.esb.samples.quickstart.webservice_wsproxy_basic.test.SendWSMessage class and passes
- in and argument representing the *PROXIED* webservice endpoint and an argument representing the
- string-based message to invoke the webserivce with.
+ org.jboss.soa.esb.samples.quickstart.webservice_wsproxy_basic.test.SendWSMessage class and
+ passes in and argument representing the *PROXIED* webservice endpoint and an argument
+ representing the string-based message to invoke the webserivce with.
+
Added: labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/src/response.xsl
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/src/response.xsl (rev 0)
+++ labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/src/response.xsl 2009-06-26 23:23:41 UTC (rev 27164)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
+
+ <xsl:template match="return">
+ <transformedReturn><xsl:value-of select="."/></transformedReturn>
+ </xsl:template>
+
+ <xsl:template match="*">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="comment()|processing-instruction()">
+ <xsl:copy/>
+ </xsl:template>
+
+</xsl:stylesheet>
Property changes on: labs/jbossesb/workspace/dward/wsproxy/product/samples/quickstarts/webservice_wsproxy_basic/src/response.xsl
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java 2009-06-26 23:23:41 UTC (rev 27164)
@@ -150,7 +150,7 @@
* @return The WSDL.
* @throws IOException Error reading wsdl.
*/
- private String getWsdl(String wsdlAddress) throws IOException {
+ public String getWsdl(String wsdlAddress) throws IOException {
RemoteWsdlLoader loader;
try {
Modified: labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2009-06-26 23:23:41 UTC (rev 27164)
@@ -20,21 +20,30 @@
package org.jboss.soa.esb.actions.soap.proxy;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.StringReader;
-import java.net.MalformedURLException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.publish.Publish;
+import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.actions.soap.WsdlContractPublisher;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
@@ -61,28 +70,41 @@
* (the client no longer has a direct connection to the remote service's hostname/IP address). The client will see modified WSDL
* so that the client is pointed to the ESB's exposed endpoint instead of the original, now proxied endpoint.<p/>
*
- * Only a single configuration property is needed for the SOAPProxy: the original "<b>wsdl</b>" (whose endpoint will get re-written
- * and exposed as new wsdl from the ESB). Depending upon the <definitions><service><port><soap:address
- * location attribute's protocol (for example "http"), a protocol-specific {@link SOAPProxyTransport} implementation is used. For
- * other possible configuration properties, see the specific {@link SOAPProxyTransport} implementations themselves.<p/>
+ * <i>Configuration</i><br/>
+ * <ol>
+ * <li><b>wsdl</b> (required): The original wsdl {@link URL url} whose WS endpoint will get re-written and exposed as new wsdl from
+ * the ESB. Depending upon the <definitions><service><port><soap:address location attribute's protocol (for
+ * example "http"), a protocol-specific {@link SOAPProxyTransport} implementation is used.</li>
+ * <li><b>request-xsl</b> (optional): The {@link File file}path/{@link Class class}path/{@link URL url} XSL which will transform
+ * the request message payload (the SOAP Envelope) <i>before</i> the external endpoint is invoked.</li>
+ * <li><b>response-xsl</b> (optional): The {@link File file}path/{@link Class class}path/{@link URL url} XSL which will transform
+ * the response message payload (the SOAP Envelope) <i>after</i> the external endpoint is invoked.</li>
+ * </ol>
+ * For other possible configuration properties, see the specific {@link SOAPProxyTransport} implementations themselves.<p/>
*
* <i>Example:</i><br/>
* <pre>
* <action name="wsproxy" class="org.jboss.soa.esb.actions.soap.proxy.SOAPProxy">
- * <property name="wsdl" value="http://127.0.0.1:8080/path/HelloWorldWebService?wsdl"/>
+ * <property name="wsdl" value="http://127.0.0.1:8080/path/HelloWorldWebService?wsdl"/> <!-- required -->
+ * <property name="request-xsl" value="/request.xsl"/> <!-- optional -->
+ * <property name="response-xsl" value="/response.xsl"/> <!-- optional -->
* </action>
* </pre>
*
* @author dward at jboss.org
*/
- at Publish(WsdlContractPublisher.class)
+ at Publish(SOAPProxyWsdlContractPublisher.class)
public class SOAPProxy extends AbstractActionPipelineProcessor
{
private static Logger logger = Logger.getLogger(SOAPProxy.class);
+ private static TransformerFactory transformerFactory = TransformerFactory.newInstance();
private MessagePayloadProxy payloadProxy;
+ private byte[] request_xsl_bytes = null;
+ private byte[] response_xsl_bytes = null;
+
private Map<String,String> soapaction_to_binding = new HashMap<String,String>();
private Map<String,String> operation_to_binding = new HashMap<String,String>();
private Map<String,SOAPProxyTransport> binding_to_transport = new HashMap<String,SOAPProxyTransport>();
@@ -90,17 +112,8 @@
public SOAPProxy(ConfigTree config) throws ConfigurationException
{
payloadProxy = new MessagePayloadProxy(config);
- String wsdl = config.getRequiredAttribute("wsdl");
- URL wsdl_url;
- try
- {
- wsdl_url = new URL( wsdl.trim() );
- }
- catch (MalformedURLException mue)
- {
- throw new ConfigurationException(mue);
- }
WSDLDefinitionsFactory wsdl_def_fact = WSDLDefinitionsFactory.newInstance();
+ URL wsdl_url = SOAPProxyWsdlContractPublisher.createLocalWsdlURL(config);
WSDLDefinitions wsdl_def = wsdl_def_fact.parse(wsdl_url);
for ( WSDLBinding wsdl_bind : wsdl_def.getBindings() )
{
@@ -161,6 +174,16 @@
}
}
}
+ String request_xsl = config.getAttribute("request-xsl");
+ if (request_xsl != null)
+ {
+ request_xsl_bytes = StreamUtils.getResourceAsBytes(request_xsl);
+ }
+ String response_xsl = config.getAttribute("response-xsl");
+ if (response_xsl != null)
+ {
+ response_xsl_bytes = StreamUtils.getResourceAsBytes(response_xsl);
+ }
}
public void initialise() throws ActionLifecycleException
@@ -178,6 +201,10 @@
String operation = null;
if (binding == null)
{
+ if ( logger.isEnabledFor(Level.WARN) )
+ {
+ logger.warn("\"SOAPAction\" should be set! Resorting to (potentially expensive) parsing of SOAP Body to guess operation!");
+ }
operation = getOperation(message);
binding = (operation != null) ? operation_to_binding.get(operation) : null;
}
@@ -186,14 +213,20 @@
{
throw new ActionProcessingException("null transport for soapaction [" + soapaction + "], operation [" + operation + "], binding [" + binding + "]");
}
- else
+ if ( logger.isDebugEnabled() )
{
- if ( logger.isDebugEnabled() )
- {
- logger.debug("using transport [" + transport.getClass().getName() + "] with endpoint address: [" + transport.getEndpointAddress() + "] for binding [" + binding + "]");
- }
- return transport.process(message);
+ logger.debug("using transport [" + transport.getClass().getName() + "] with endpoint address: [" + transport.getEndpointAddress() + "] for binding [" + binding + "]");
}
+ if (request_xsl_bytes != null)
+ {
+ transformPayload(message, request_xsl_bytes);
+ }
+ message = transport.process(message);
+ if (response_xsl_bytes != null)
+ {
+ transformPayload(message, response_xsl_bytes);
+ }
+ return message;
}
public void destroy() throws ActionLifecycleException
@@ -204,6 +237,58 @@
}
}
+ private void transformPayload(Message message, byte[] xsl_bytes) throws ActionProcessingException
+ {
+ ByteArrayInputStream xsl_input_stream = new ByteArrayInputStream(xsl_bytes);
+ ByteArrayOutputStream xsl_output_stream = null;
+ Writer xsl_output_writer = null;
+ try
+ {
+ StreamSource xsl_input = null;
+ Object payload = payloadProxy.getPayload(message);
+ if (payload instanceof byte[])
+ {
+ xsl_input = new StreamSource( new ByteArrayInputStream((byte[])payload) );
+ xsl_output_stream = new ByteArrayOutputStream();
+ }
+ else if (payload instanceof String)
+ {
+ xsl_input = new StreamSource( new StringReader((String)payload) );
+ xsl_output_writer = new StringWriter();
+ }
+ else
+ {
+ throw new ActionProcessingException( "unsupported payload type: " + payload.getClass().getName() );
+ }
+ Transformer transformer = transformerFactory.newTransformer( new StreamSource(xsl_input_stream) );
+ if (xsl_output_stream != null)
+ {
+ transformer.transform( xsl_input, new StreamResult(xsl_output_stream) );
+ payloadProxy.setPayload( message, xsl_output_stream.toByteArray() );
+ }
+ else
+ {
+ transformer.transform( xsl_input, new StreamResult(xsl_output_writer) );
+ payloadProxy.setPayload( message, xsl_output_writer.toString() );
+ }
+ }
+ catch (MessageDeliverException mde)
+ {
+ throw new ActionProcessingException(mde);
+ }
+ catch (TransformerException te)
+ {
+ throw new ActionProcessingException(te);
+ }
+ finally
+ {
+ try { if (xsl_input_stream != null) xsl_input_stream.close(); } catch (Throwable t) {}
+ try { if (xsl_output_stream != null) xsl_output_stream.close(); } catch (Throwable t) {}
+ try { if (xsl_output_writer != null) xsl_output_writer.close(); } catch (Throwable t) {}
+ }
+ }
+
+ // This is a best (and potentially expensive) guess! See logger.warn(String) warning in process(Message) above.
private String getOperation(Message message) throws ActionProcessingException
{
Object payload;
Added: labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java (rev 0)
+++ labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java 2009-06-26 23:23:41 UTC (rev 27164)
@@ -0,0 +1,100 @@
+/*
+ * 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-2009
+ */
+package org.jboss.soa.esb.actions.soap.proxy;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.soap.wise.WiseWsdlContractPublisher;
+import org.jboss.soa.esb.helpers.ConfigTree;
+
+/**
+ * Provides convenience method to load the remote wsdl respecting all configured HttpClient properties.
+ *
+ * @author dward at jboss.org
+ */
+public class SOAPProxyWsdlContractPublisher extends WiseWsdlContractPublisher
+{
+
+ private static Logger logger = Logger.getLogger(SOAPProxyWsdlContractPublisher.class);
+
+ static URL createLocalWsdlURL(ConfigTree config) throws ConfigurationException
+ {
+ Writer writer = null;
+ try
+ {
+ WsdlLoader loader = new WsdlLoader(config);
+ String wsdl = loader.getWsdl( config.getRequiredAttribute("wsdl") );
+ File file = File.createTempFile(SOAPProxyWsdlContractPublisher.class.getName() + "-", ".wsdl");
+ file.deleteOnExit();
+ writer = new BufferedWriter( new FileWriter(file) );
+ writer.write(wsdl);
+ writer.flush();
+ URL url = file.toURL();
+ if ( logger.isDebugEnabled() )
+ {
+ logger.debug("created local wsdl url: " + url);
+ }
+ return url;
+ }
+ catch (IOException ioe)
+ {
+ throw new ConfigurationException(ioe);
+ }
+ finally
+ {
+ try { if (writer != null) writer.close(); } catch (Throwable t) {}
+ }
+ }
+
+ private static class WsdlLoader extends SOAPProxyWsdlContractPublisher
+ {
+
+ private ConfigTree config;
+
+ private WsdlLoader(ConfigTree config)
+ {
+ this.config = config;
+ }
+
+ public Properties getActionProperties()
+ {
+ Properties props = new Properties();
+ for ( String key : config.getAttributeNames() )
+ {
+ String value = config.getAttribute(key);
+ if (value != null)
+ {
+ props.setProperty(key, value);
+ }
+ }
+ return props;
+ }
+
+ }
+
+}
Property changes on: labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java 2009-06-26 23:12:33 UTC (rev 27163)
+++ labs/jbossesb/workspace/dward/wsproxy/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java 2009-06-26 23:23:41 UTC (rev 27164)
@@ -19,17 +19,17 @@
*/
package org.jboss.soa.esb.actions.soap.wise;
+import java.util.Properties;
+
import org.jboss.soa.esb.actions.soap.WsdlContractPublisher;
-import java.util.Properties;
-
/**
* WSDL contract publisher.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class WiseWsdlContractPublisher extends WsdlContractPublisher {
- private Properties properties;
+ // [1] private Properties properties;
public Properties getHttpClientProperties() {
Properties httpClientProperties = (Properties) getActionProperties().clone();
@@ -50,14 +50,16 @@
}
}
- if(configurators == null) {
+ if(configurators != null) {
httpClientProperties.setProperty("configurators", configurators);
}
return httpClientProperties;
}
- public Properties getActionProperties() {
- return properties;
- }
+ // [1] public Properties getActionProperties() {
+ // return properties;
+ //}
+
+ // [1] Why were these here?
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list