[jboss-svn-commits] JBL Code SVN: r25155 - in labs/jbossesb/trunk/product: samples/quickstarts/webservice_consumer_wise and 9 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Feb 9 05:48:34 EST 2009
Author: kevin.conner at jboss.com
Date: 2009-02-09 05:48:33 -0500 (Mon, 09 Feb 2009)
New Revision: 25155
Added:
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/wise-core.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/wise-core.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/wise-core.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/wise-core.properties
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksHandler.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksMapper.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/
Removed:
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/jboss-web.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise_wsse_wsa/
labs/jbossesb/trunk/product/services/soap/lib/ext/jaxb-api.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/jaxb-impl.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/jbossws-native-jaxws-ext.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/jbossws-native-jaxws.jar
labs/jbossesb/trunk/product/services/soap/src/main/resources/wise-config.beans/
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/readme.txt
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/web.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-config-XMLGregorianCalendar.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-response-config.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/war/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer_wise2/PingWS.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/jboss-esb.xml
labs/jbossesb/trunk/product/services/soap/lib/ext/wise-core.jar
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
Log:
Rollback wise to 4.4CP branch codebase: JBESB-2313
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/build.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/build.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -5,6 +5,8 @@
${line.separator}
</description>
+ <property name="additional.deploys" value="wise-core.properties" />
+
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/jboss-esb.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/jboss-esb.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -46,9 +46,9 @@
<property name="SOAPAction" value="sayHello"/>
<property name="EndPointName" value="HelloWorldPort"/>
- <property name="serviceName" value="HelloWorldWSService"/>
- <property name="username" value="kermit"/>
- <property name="password" value="thefrog"/>
+ <property name="serviceName" value="HelloWorldWS"/>
+ <property name="username" value=""/>
+ <property name="password" value=""/>
</action>
<action name="response-mapper"
class="org.jboss.soa.esb.samples.quickstart.webservice_consumer_wise.MyResponseAction">
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/readme.txt 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/readme.txt 2009-02-09 10:48:33 UTC (rev 25155)
@@ -2,8 +2,8 @@
=========
This example demonstrates how to use Wise SOAPClient action to consume a 181 Web Service in an ESB action.
This ESB will make a webservice request that requires a single "toWhom" string parameter.
- The webservice will return a greeting response. WebService require HTTP BASIC Authentication.
- The ESB simply displays the request and response on the console.
+ The webservice will return a greeting response. The ESB simply displays the request and response on the
+ console.
Running this quickstart:
========================
Deleted: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/jboss-web.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/jboss-web.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/jboss-web.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -1,3 +0,0 @@
-<jboss-web>
- <security-domain>java:/jaas/JBossWS</security-domain>
-</jboss-web>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/web.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/web.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/war/resources/WEB-INF/web.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -4,7 +4,7 @@
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>HelloWorldWS</servlet-name>
- <servlet-class>org.jboss.soa.esb.samples.quickstart.webservice_consumer1.HelloWorldWS</servlet-class>
+ <servlet-class>org.jboss.soa.esb.samples.quickstart.webservice_consumer1.HelloWorldWS</servlet-class>
</servlet>
<servlet-mapping>
@@ -12,26 +12,4 @@
<url-pattern>/HelloWorldWS</url-pattern>
</servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>All resources</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>friend</role-name>
- </auth-constraint>
- </security-constraint>
-
- <security-role>
- <role-name>friend</role-name>
- </security-role>
-
-
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>Test Realm</realm-name>
- </login-config>
-
-
</web-app>
Copied: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/wise-core.properties (from rev 25154, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/webservice_consumer_wise/wise-core.properties)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/wise-core.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise/wise-core.properties 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,4 @@
+wise.tmpDir=/home/oracle/wise
+wise.forceImportObject=true
+wise.keepGeneratedSources=true
+wise.wsImporter.verbose=true
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/build.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/build.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -5,7 +5,7 @@
${line.separator}
</description>
- <property name="additional.deploys" value="smooks-config-XMLGregorianCalendar.xml,smooks-response-config.xml" />
+ <property name="additional.deploys" value="wise-core.properties,smooks-config-XMLGregorianCalendar.xml,smooks-response-config.xml" />
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/jboss-esb.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/jboss-esb.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -47,10 +47,9 @@
<property name="EndPointName" value="PingWSPort"/>
<property name="SmooksRequestMapper" value="smooks-config-XMLGregorianCalendar.xml"/>
<property name="SmooksResponseMapper" value="smooks-response-config.xml"/>
- <!-- <property name="smooksResponseReport" value="/home/oracle/smooks-response.html"/>-->
<property name="LoggingMessages" value="false" />
- <property name="serviceName" value="PingWSService"/>
- <property name="userName" value=""/>
+ <property name="serviceName" value="PingWS"/>
+ <property name="username" value=""/>
<property name="password" value=""/>
</action>
<action name="response-mapper"
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-config-XMLGregorianCalendar.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-config-XMLGregorianCalendar.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-config-XMLGregorianCalendar.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -8,7 +8,7 @@
<resource-config selector="org.jboss.soa.esb.samples.quickstart.webservice__consumer__wise2.ExternalObject">
<resource>org.milyn.javabean.BeanPopulator</resource>
<param name="beanId">complexObject</param>
- <param name="beanClass">wise2.pingws.ComplexObject</param>
+ <param name="beanClass">it.javalinux.wise.ComplexObject</param>
<param name="bindings">
<binding property="integerField" type="Integer" selector="internal number" />
<binding property="stringField" selector="internal text" />
@@ -16,8 +16,8 @@
</param>
</resource-config>
<resource-config selector="decoder:XMLGregorianCalendar">
- <resource>org.jboss.wise.smooks.decoders.XMLGregorianCalendarDecoder</resource>
+ <resource>it.javalinux.wise.smooks.decoders.XMLGregorianCalendarDecoder</resource>
<param name="format">yyyy-MM-dd HH:mm:ss.S z</param>
</resource-config>
-</smooks-resource-list>
\ No newline at end of file
+</smooks-resource-list>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-response-config.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-response-config.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/smooks-response-config.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -5,7 +5,7 @@
<param name="stream.filter.type">SAX</param>
</resource-config>
- <resource-config selector="wise2.pingws.ComplexObject">
+ <resource-config selector="it.javalinux.wise.ComplexObject">
<resource>org.milyn.javabean.BeanPopulator</resource>
<param name="beanId">ExternalObject</param>
<param name="beanClass">org.jboss.soa.esb.samples.quickstart.webservice_consumer_wise2.ExternalObject</param>
@@ -15,7 +15,7 @@
</param>
</resource-config>
- <resource-config selector="wise2.pingws.ComplexObject">
+ <resource-config selector="it.javalinux.wise.ComplexObject">
<resource>org.milyn.javabean.BeanPopulator</resource>
<param name="beanId">InternalObject</param>
<param name="beanClass">org.jboss.soa.esb.samples.quickstart.webservice_consumer_wise2.InternalObject</param>
@@ -25,7 +25,7 @@
</param>
</resource-config>
- <resource-config selector="wise2.pingws.ComplexObject">
+ <resource-config selector="it.javalinux.wise.ComplexObject">
<resource>org.milyn.javabean.BeanPopulator</resource>
<param name="beanId">messageDate</param>
<param name="beanClass">java.util.HashMap</param>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/war/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer_wise2/PingWS.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/war/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer_wise2/PingWS.java 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/war/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer_wise2/PingWS.java 2009-02-09 10:48:33 UTC (rev 25155)
@@ -28,7 +28,7 @@
import org.jboss.logging.Logger;
- at WebService(name = "PingWS", targetNamespace = "http://wise2/pingws")
+ at WebService(name = "PingWS", targetNamespace = "http://webservice_consumer_wise2/pingws")
public class PingWS {
@WebMethod(operationName = "pingComplexObject", action = "urn:pingComplexObject")
@WebResult(name = "ComplexObject")
Copied: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/wise-core.properties (from rev 25154, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/webservice_consumer_wise2/wise-core.properties)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/wise-core.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2/wise-core.properties 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,4 @@
+wise.tmpDir=/home/oracle/wise
+wise.forceImportObject=true
+wise.keepGeneratedSources=true
+wise.wsImporter.verbose=true
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/build.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/build.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -5,7 +5,7 @@
${line.separator}
</description>
- <property name="additional.deploys" value="smooks-handler.xml" />
+ <property name="additional.deploys" value="wise-core.properties,smooks-handler.xml" />
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/jboss-esb.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/jboss-esb.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -48,8 +48,8 @@
<property name="LoggingMessages" value="true" />
<property name="smooks-handler-config" value="smooks-handler.xml"></property>
- <property name="serviceName" value="HelloWorldWSService"/>
- <property name="userName" value=""/>
+ <property name="serviceName" value="HelloWorldWS"/>
+ <property name="username" value=""/>
<property name="password" value=""/>
</action>
Copied: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/wise-core.properties (from rev 25154, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/webservice_consumer_wise3/wise-core.properties)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/wise-core.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise3/wise-core.properties 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,4 @@
+wise.tmpDir=/home/oracle/wise
+wise.forceImportObject=true
+wise.keepGeneratedSources=true
+wise.wsImporter.verbose=true
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/build.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/build.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -5,7 +5,7 @@
${line.separator}
</description>
- <property name="additional.deploys" value="smooks-handler.xml" />
+ <property name="additional.deploys" value="wise-core.properties,smooks-handler.xml" />
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/jboss-esb.xml 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/jboss-esb.xml 2009-02-09 10:48:33 UTC (rev 25155)
@@ -48,8 +48,8 @@
<property name="LoggingMessages" value="true" />
<property name="smooks-handler-config" value="smooks-handler.xml"></property>
<property name="custom-handlers" value="org.jboss.soa.esb.samples.quickstart.webservice_consumer_wise4.handler.MyCustomLoggingHandler;org.jboss.soa.esb.samples.quickstart.webservice_consumer_wise4.handler.MyCustomLoggingHandler2" />
- <property name="serviceName" value="HelloWorldWSService"/>
- <property name="userName" value=""/>
+ <property name="serviceName" value="HelloWorldWS"/>
+ <property name="username" value=""/>
<property name="password" value=""/>
</action>
Copied: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/wise-core.properties (from rev 25154, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/webservice_consumer_wise4/wise-core.properties)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/wise-core.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise4/wise-core.properties 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,4 @@
+wise.tmpDir=/home/oracle/wise
+wise.forceImportObject=true
+wise.keepGeneratedSources=true
+wise.wsImporter.verbose=true
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/jaxb-api.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/jaxb-impl.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/jbossws-native-jaxws-ext.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/jbossws-native-jaxws.jar
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/services/soap/lib/ext/wise-core.jar
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2009-02-09 09:03:26 UTC (rev 25154)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2009-02-09 10:48:33 UTC (rev 25155)
@@ -22,41 +22,36 @@
package org.jboss.soa.esb.actions.soap.wise;
-import java.io.File;
+import it.javalinux.wise.core.client.InvocationResult;
+import it.javalinux.wise.core.client.WSDynamicClient;
+import it.javalinux.wise.core.client.WSEndpoint;
+import it.javalinux.wise.core.client.WSMethod;
+import it.javalinux.wise.core.client.handler.LoggingHandler;
+import it.javalinux.wise.core.exceptions.WiseException;
+import it.javalinux.wise.core.mapper.WiseMapper;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import javax.xml.ws.handler.Handler;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.publish.Publish;
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.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.MessagePayloadProxy;
-import org.jboss.wise.core.client.InvocationResult;
-import org.jboss.wise.core.client.WSDynamicClient;
-import org.jboss.wise.core.client.WSEndpoint;
-import org.jboss.wise.core.client.WSMethod;
-import org.jboss.wise.core.client.factories.WSDynamicClientFactory;
-import org.jboss.wise.core.handlers.LoggingHandler;
-import org.jboss.wise.core.handlers.SmooksHandler;
-import org.jboss.wise.core.mapper.SmooksMapper;
-import org.jboss.wise.core.mapper.WiseMapper;
-import org.jboss.wise.core.wsextensions.impl.MTOMEnabler;
-import org.jboss.wise.core.wsextensions.impl.WSAddressingEnabler;
-import org.jboss.wise.core.wsextensions.impl.WSSecurityEnabler;
-import org.jboss.internal.soa.esb.publish.Publish;
-import org.apache.log4j.Logger;
/**
- * SOAP Client action processor.
- * <p/>
- * Uses the Wise Client Service to generate JAXWS client class and call the target service. This action then routes that message
- * to that service.
- * <h2>Endpoint Operation Specification</h2> Specifying the endpoint operation is a straightforward task. Simply specify the
- * "wsdl" and "SOAPAction" properties on the SOAPClient action as follows:
+ * SOAP Client action processor. <p/> Uses the Wise Client Service to generate JAXWS client class and call the target service.
+ * This action then routes that message to that service.
+ * <h2>Endpoint Operation Specification</h2>
+ * Specifying the endpoint operation is a straightforward task. Simply specify the "wsdl" and "SOAPAction" properties on the
+ * SOAPClient action as follows:
*
* <pre>
* <action name="soap-wise-client-action" class="org.jboss.soa.esb.actions.soap.wise.SOAPClient">
@@ -94,47 +89,48 @@
*
* <pre>
* <property name="userName" value=""/>
- * <property name="password" value=""/>
+ * <property name="password" value=""/>
* </pre>
*
- * User and password used if webservice is protected by BAsic Authentication HTTP user and password <h2
- * id="request-construction">SOAP Request Message Construction</h2> The SOAP operation parameters are supplied in one of 2 ways:
+ * User and password used if webservice is protected by BAsic Authentication HTTP user and password
+ * <h2 id="request-construction">SOAP Request Message Construction</h2>
+ * The SOAP operation parameters are supplied in one of 2 ways:
* <ol>
* <li>As a {@link Map} instance set on the <i>default body location</i> (Message.getBody().add(Map))</li>
* <li>As a {@link Map} instance set on in a <i>named body location</i> (Message.getBody().add(String, Map)), where the name of
- * that body location is specified as the value of the "paramsLocation" action property.</li>
+ * that body location is specified as the value of the "paramsLocation" action property. </li>
* </ol>
* The parameter {@link Map} itself can also be populated in one of 2 ways:
* <ol>
* <li><b>Option 1</b>: With a set of Objects of any type. In this case a smooks config have to be specified in action attribute
* SmooksRequestMapper and smooks is used to make the java-to-java conversion
- * <li><b>Option 2</b>: With a set of String based key-value pairs(<String, Object>), where the key is the name of the SOAP
- * parameter as specified in wsdls (or in generated class) to be populated with the key's value.</li>
+ * <li><b>Option 2</b>: With a set of String based key-value pairs(<String, Object>), where the key is the name of the
+ * SOAP parameter as specified in wsdls (or in generated class) to be populated with the key's value. </li>
* </ol>
- * <h2>SOAP Response Message Consumption</h2> The SOAP response object instance can be is attached to the ESB {@link Message}
- * instance in one of the following ways:
+ * <h2>SOAP Response Message Consumption</h2>
+ * The SOAP response object instance can be is attached to the ESB {@link Message} instance in one of the following ways:
* <ol>
* <li>On the <i>default body location</i> (Message.getBody().add(Map))</li>
- * <li>On in a <i>named body location</i> (Message.getBody().add(String, Map)), where the name of that body location is specified
- * as the value of the "responseLocation" action property.</li>
+ * <li>On in a <i>named body location</i> (Message.getBody().add(String, Map)), where the name of that body location is
+ * specified as the value of the "responseLocation" action property. </li>
* </ol>
* The response object instance can also be populated (from the SOAP response) in one of 3 ways:
* <ol>
* <li><b>Option 1</b>: With a set of Objects of any type. In this case a smooks config have to be specified in action attribute
* SmooksResponseMapper and smooks is used to make the java-to-java conversion
- * <li><b>Option 2</b>: With a set of String based key-value pairs(<String, Object>), where the key is the name of the SOAP
- * answer as specified in wsdls (or in generated class) to be populated with the key's value.</li>
+ * <li><b>Option 2</b>: With a set of String based key-value pairs(<String, Object>), where the key is the name of the
+ * SOAP answer as specified in wsdls (or in generated class) to be populated with the key's value. </li>
* </ol>
- * <h2>JAX-WS Handler for the SOAP Request/Response Message</h2> It's often necessary to be able to transform the SOAP request or
- * response, especially in header. This may be to simply add some standard SOAP handlers. Wise support JAXWS Soap Handler, both
- * custom or a predefined one based on smooks.
- * <p/>
- * Transformation of the SOAP request (before sending) is supported by configuring the SOAPClient action with a Smooks
- * transformation configuration property as follows:
+ * <h2>JAX-WS Handler for the SOAP Request/Response Message</h2>
+ * It's often necessary to be able to transform the SOAP request or response, especially in header. This may be to simply add some
+ * standard SOAP handlers. Wise support JAXWS Soap Handler, both custom or a predefined one based on smooks. <p/> Transformation
+ * of the SOAP request (before sending) is supported by configuring the SOAPClient action with a Smooks transformation
+ * configuration property as follows:
*
* <pre>
* <property name="smooksTransform" value="/transforms/order-transform.xml" />
* </pre>
+ *
* <p>
* 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.
@@ -148,8 +144,9 @@
* <property name="custom-handlers" value="package.Class1;package.Class2" />
* </pre>
*
- * <h2>Logging the SOAP Request/Response Message</h2> It's useful for debug purpose to view soap Message sent and response
- * received. Wise achieve this goal using a JAX-WS handler printing all messages exchanged on System.out You can enable as follow:
+ * <h2>Logging the SOAP Request/Response Message</h2>
+ * It's useful for debug purpose to view soap Message sent and response received. Wise achieve this goal using a JAX-WS handler
+ * printing all messages exchanged on System.out You can enable as follow:
*
* <pre>
* <property name="LoggingMessages" value="true" />
@@ -166,226 +163,250 @@
private final String endPointName;
private final String smooksRequestMapperURL;
private final String smooksResponseMapperURL;
+ private final WiseMapper smooksRequestMapper;
+ private final WiseMapper smooksResponseMapper;
+ private String operationName;
private String serviceName;
private final String username;
private final String password;
- private final String catalogFileName;
private final List<String> smooksHandler = new ArrayList<String>();
private final List<String> customHandlers = new ArrayList<String>();
- private final List<String> bindingFileNames = new ArrayList<String>();
private final MessagePayloadProxy payloadProxy;
private boolean loggingEnabled = false;
- private boolean wsseEnabled = false;
- private boolean wsaEnabled = false;
- private boolean mtomEnabled = false;
- private String smooksRequestReport = null;
- private String smooksResponseReport = null;
- private String targetPackage = null;
-
- private WSMethod method = null;
- private WSEndpoint endpoint;
-
- public SOAPClient( ConfigTree config ) throws ConfigurationException {
+
+ private WSDynamicClient client;
+
+ public SOAPClient(final ConfigTree config ) throws ConfigurationException
+ {
wsdl = config.getRequiredAttribute("wsdl");
- soapAction = config.getRequiredAttribute("SOAPAction");
+ soapAction = config.getAttribute("SOAPAction");
endPointName = config.getRequiredAttribute("EndPointName");
smooksRequestMapperURL = config.getAttribute("SmooksRequestMapper");
+ smooksRequestMapper = createSmooksMapper(smooksRequestMapperURL) ;
smooksResponseMapperURL = config.getAttribute("SmooksResponseMapper");
+ smooksResponseMapper = createSmooksMapper(smooksResponseMapperURL) ;
serviceName = config.getAttribute("serviceName");
serviceName = serviceName != null ? serviceName : wsdl.substring(wsdl.lastIndexOf("/"), wsdl.lastIndexOf("?"));
username = config.getAttribute("username");
password = config.getAttribute("password");
- smooksRequestReport = config.getAttribute("smooksRequestReport");
- smooksResponseReport = config.getAttribute("smooksResponseReport");
- logger.info(config.getAttribute("LoggingMessages"));
loggingEnabled = Boolean.parseBoolean(config.getAttribute("LoggingMessages"));
logger.info("loggingEnabled:" + loggingEnabled);
- wsseEnabled = Boolean.parseBoolean(config.getAttribute("enableWSSE"));
- logger.info("wsseEnabled:" + wsseEnabled);
- wsaEnabled = Boolean.parseBoolean(config.getAttribute("enableWSA"));
- logger.info("wsaEnabled:" + wsaEnabled);
- mtomEnabled = Boolean.parseBoolean(config.getAttribute("enableMTOM"));
- logger.info("mtomEnabled:" + mtomEnabled);
- targetPackage = config.getAttribute("targetPackage");
- ConfigTree[] handlersConfig;
- if (config.getAttribute("smooks-handler-config") != null) {
+
+ if (config.getAttribute("smooks-handler-config") != null)
+ {
smooksHandler.add(config.getAttribute("smooks-handler-config"));
}
- if (config.getAttribute("custom-handlers") != null) {
- for (String className : config.getAttribute("custom-handlers").split(";")) {
+
+ if (config.getAttribute("custom-handlers") != null)
+ {
+ for (String className : config.getAttribute("custom-handlers").split(";"))
+ {
customHandlers.add(className);
}
-
}
- if (config.getAttribute("binding-files") != null) {
- for (String fileName : config.getAttribute("binding-files").split(";")) {
- bindingFileNames.add(fileName);
+ operationName = config.getAttribute("operationName");
+
+ if (operationName == null)
+ {
+ if (soapAction == null)
+ {
+ throw new ConfigurationException("Missing operationName or soapAction") ;
}
-
+ final int pathIndex = soapAction.lastIndexOf('/') ;
+
+ if (pathIndex >= 0)
+ {
+ if (pathIndex == soapAction.length() -1)
+ {
+ throw new ConfigurationException("Invalid soapAction, cannot end with '/'") ;
+ }
+ operationName = soapAction.substring(pathIndex+1) ;
+ }
+ else
+ {
+ operationName = soapAction;
+ }
}
-
- catalogFileName = config.getAttribute("catalog-file");
-
- handlersConfig = config.getChildren("custom-handlers");
-
+
payloadProxy = new MessagePayloadProxy(config);
-
}
+
+ public Message process(final Message message) throws ActionProcessingException
+ {
+ WSDynamicClient client = createClient(wsdl, serviceName, username, password);
+ WSEndpoint endpoint = getEndpoint(client);
+
+ Object payload = getMessagePayload(message);
+ addSmooksHandlers(endpoint, payload);
+ addCustomHandlers(endpoint);
+ addLoggingHandler(endpoint);
+
+ WSMethod wsMethod = getWSMethodFromEndpoint(operationName, endpoint);
- @Override
- public void initialise() throws ActionLifecycleException {
- WSDynamicClientFactory.initialise();
- }
-
- private void beforeFirstCall() throws ActionProcessingException {
- WSDynamicClient client = null;
- logger.info("DEPLOY #1");
- // get client from cache
- try {
- List<File> bindings = new java.util.ArrayList<File>();
-
- for (String fileName : bindingFileNames) {
- File bindFile = new File(fileName);
- bindings.add(bindFile);
+ InvocationResult result;
+ try
+ {
+ result = wsMethod.invoke(payload, smooksRequestMapper);
+ }
+ catch (final WiseException e)
+ {
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("Exception thrown from wsMethod invocation", e) ;
}
- File catalog = null;
- if (catalogFileName != null) {
- catalog = new File(catalogFileName);
- }
- client = WSDynamicClientFactory.getInstance().getJAXWSClient(wsdl,
- username,
- password,
- targetPackage,
- bindings,
- catalog);
- } catch (Exception e) {
- e.printStackTrace();
- throw new ActionProcessingException("Error durinfg wise client creation", e);
+ throw new ActionProcessingException("Could not call method" + operationName, e);
}
- logger.info("DEPLOY #2");
- this.setMethod(client.getWSMethod(this.serviceName, this.endPointName, this.soapAction));
- logger.info("DEPLOY #3");
- this.setEndpoint(this.getMethod().getEndpoint());
- logger.info("DEPLOY #4");
- for (String config : customHandlers) {
- logger.info("adding custom handler:" + config);
- try {
- Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
- this.getEndpoint().addHandler((Handler)clazz.newInstance());
- } catch (Exception e) {
- logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
+ return mapResponseToMessage(message, result, smooksResponseMapper);
+ }
+
+ synchronized WSDynamicClient createClient(final String wsdl, final String serviceName, final String username, final String password) throws ActionProcessingException
+ {
+ if (client == null)
+ {
+ try
+ {
+ client = new WSDynamicClientFactory().create(wsdl, serviceName, username, password);
+ }
+ catch (final WiseException e)
+ {
+ throw new ActionProcessingException(e.getMessage(), e);
}
+ // Force endpoints to prevent JBossWS concurrency issues
+ getEndpoints(client) ;
}
+ return client;
+ }
- if (loggingEnabled) {
- logger.info("adding logging handler");
- this.getEndpoint().addHandler(new LoggingHandler());
+ private WSEndpoint getEndpoint(final WSDynamicClient client)
+ {
+ Map<String, WSEndpoint> endpointsMap = getEndpoints(client);
+
+ WSEndpoint endpoint;
+ if (endPointName != null) {
+ endpoint = endpointsMap.get(endPointName);
+ } else {
+ endpoint = endpointsMap.values().iterator().next();
}
- try {
- if (wsseEnabled) {
- logger.info("enabling wsse");
- this.getEndpoint().addWSExtension(new WSSecurityEnabler());
- }
- if (wsaEnabled) {
- logger.info("enabling wsa");
- this.getEndpoint().addWSExtension(new WSAddressingEnabler());
- }
- if (mtomEnabled) {
- logger.info("enabling mtom");
- this.getEndpoint().addWSExtension(new MTOMEnabler());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
+ return endpoint;
}
- @Override
- public void destroy() throws ActionLifecycleException {
- // nop
+ private Object getMessagePayload(final Message message) throws ActionProcessingException
+ {
+ try
+ {
+ return payloadProxy.getPayload(message);
+ }
+ catch (final MessageDeliverException e)
+ {
+ throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
+ }
}
- public Message process( final Message message ) throws ActionProcessingException {
-
- if (this.getMethod() == null) {
- this.beforeFirstCall();
+ private void addSmooksHandlers(final WSEndpoint endpoint, final Object params)
+ throws ActionProcessingException
+ {
+ try
+ {
+ for (String config : smooksHandler)
+ {
+ logger.info("adding smooks handler:" + config);
+ if (params instanceof Map)
+ {
+ endpoint.addHandler(new SmooksHandler(config, (Map)params));
+ }
+ else
+ {
+ endpoint.addHandler(new SmooksHandler(config, null));
+ }
+ }
}
- Object params;
- WiseMapper responseMapper = null;
- WiseMapper requestMapper = null;
-
- if (this.smooksRequestMapperURL != null) {
- requestMapper = new SmooksMapper(this.smooksRequestMapperURL, this.smooksRequestReport);
+ catch (final RuntimeException re)
+ {
+ throw re ;
}
-
- if (this.smooksResponseMapperURL != null) {
- responseMapper = new SmooksMapper(this.smooksResponseMapperURL, this.smooksResponseReport);
+ catch (final Exception ex)
+ {
+ throw new ActionProcessingException("Unexpected exception while adding smooks handlers", ex) ;
}
+ }
- try {
- params = payloadProxy.getPayload(message);
- } catch (MessageDeliverException e) {
- throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
+ private void addCustomHandlers(final WSEndpoint endpoint)
+ {
+ for (String config : customHandlers)
+ {
+ logger.info("adding custom handler:" + config);
+ try
+ {
+ Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
+ endpoint.addHandler((Handler)clazz.newInstance());
+ }
+ catch (final Exception e)
+ {
+ logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
+ }
}
+ }
- for (String config : smooksHandler) {
- logger.info("adding smooks handler:" + config);
- if (params instanceof Map) {
- this.getEndpoint().addHandler(new SmooksHandler(config, (Map)params));
- } else {
- this.getEndpoint().addHandler(new SmooksHandler(config, null));
- }
+ private void addLoggingHandler(final WSEndpoint endpoint)
+ {
+ if (loggingEnabled)
+ {
+ logger.info("adding logging handler");
+ endpoint.addHandler(new LoggingHandler());
}
+ }
- InvocationResult result = null;
- try {
- WSMethod wsMethod = getMethod();
- if (wsMethod == null) {
- throw new ActionProcessingException("No WsMethod found for " + this.soapAction);
- }
-
- result = wsMethod.invoke(params, requestMapper);
- } catch (Exception e) {
- e.printStackTrace();
- throw new ActionProcessingException("Could not call method" + this.soapAction, e);
+ private WSMethod getWSMethodFromEndpoint(final String name, final WSEndpoint endpoint) throws ActionProcessingException
+ {
+ Map<String, WSMethod> wsmethodsMap = endpoint.getWSMethods();
+ WSMethod wsMethod = wsmethodsMap.get(name);
+ if (wsMethod != null)
+ {
+ return wsMethod;
}
+ throw new ActionProcessingException("No WSMethod found for " + name);
+ }
+
+ Map<String, WSEndpoint> getEndpoints(final WSDynamicClient client)
+ {
+ return client.processEndpoints();
+
+ }
- try {
- Map map = result.getMapRequestAndResult(responseMapper, (Map)params);
- payloadProxy.setPayload(message, map);
- } catch (Exception e) {
+ private Message mapResponseToMessage(final Message message, final InvocationResult result, final WiseMapper mapper) throws ActionProcessingException
+ {
+ try
+ {
+ payloadProxy.setPayload(message, result.getMappedResult(mapper));
+ }
+ catch (final Exception e)
+ {
throw new ActionProcessingException("Could not set payload to SOAP message", e);
}
-
return message;
}
- /**
- * @return the method
- */
- public synchronized WSMethod getMethod() {
- return method;
+ private WiseMapper createSmooksMapper(final String url)
+ throws ConfigurationException
+ {
+ if (url != null) {
+ try {
+ return new SmooksMapper(url, "smook/report/report.html");
+ } catch (final Exception ex) {
+ throw new ConfigurationException("Unexpected exception while creating smooks mapper", ex) ;
+ }
+ }
+ return null;
}
-
- /**
- * @param method the method to set
- */
- public synchronized void setMethod( WSMethod method ) {
- this.method = method;
+
+ @Override
+ public String toString()
+ {
+ return "Wise SOAPClient [wsdl=" + wsdl + ", soapAction=" + soapAction + ", endPointName=" + endPointName + ", serviceName=" + serviceName + ", smooksRequestMapperURL=" + smooksRequestMapperURL + ", smooksResponseMapperURL=" + smooksResponseMapperURL + "]";
}
-
- /**
- * @return the endpoint
- */
- public synchronized WSEndpoint getEndpoint() {
- return endpoint;
+
+ String getOperationName()
+ {
+ return operationName;
}
-
- /**
- * @param endpoint the endpoint to set
- */
- public synchronized void setEndpoint( WSEndpoint endpoint ) {
- this.endpoint = endpoint;
- }
-
}
Copied: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksHandler.java (from rev 25153, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksHandler.java)
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksHandler.java 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,176 @@
+/**
+ * WISE Invokes Services Easily - Stefano Maestri / Alessio Soldano
+ *
+ * http://www.javalinuxlabs.org - http://www.javalinux.it
+ *
+ * Wise is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software Foundation;
+ * either version 2.1 of the License, or (at your option) any later version.
+ *
+ * Wise is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details at gnu.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.milyn.Smooks;
+import org.milyn.container.ExecutionContext;
+import org.milyn.javabean.BeanAccessor;
+import org.milyn.resource.URIResourceLocator;
+import org.xml.sax.SAXException;
+
+/**
+ * A SOAPHandler extension. It apply smooks transformation on soap message.
+ * Transformation can also use freemarker, using provided javaBeans map to get
+ * values It can apply transformation only on inbound message, outbound ones or
+ * both, depending on
+ *
+ * @see #setInBoundHandlingEnabled(boolean)
+ * @see #setOutBoundHandlingEnabled(boolean)
+ *
+ * @author Stefano Maestri, stefano.maestri at javalinux.it
+ *
+ */
+public class SmooksHandler implements SOAPHandler<SOAPMessageContext> {
+
+ private String smooksResource;
+
+ private Map beansMap;
+
+ private boolean outBoundHandlingEnabled = true;
+
+ private boolean inBoundHandlingEnabled = true;
+
+ private final Smooks smooks ;
+
+ /**
+ *
+ * @param resource
+ * URI of smooks config file
+ * @param beans
+ * used for smooks BeanAccessor
+ * @throws IOException
+ * @throws SAXException
+ * @throws IllegalArgumentException
+ */
+ public SmooksHandler(String resource, Map beans) throws IllegalArgumentException, SAXException, IOException {
+ this.smooksResource = resource;
+ this.beansMap = beans;
+ smooks = new Smooks();
+ smooks.addConfigurations("smooks-resource", new URIResourceLocator().getResource(smooksResource));
+ }
+
+ public Set getHeaders() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void close(MessageContext arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean handleFault(SOAPMessageContext arg0) {
+ return false;
+ }
+
+ public boolean handleMessage(SOAPMessageContext smc) {
+ SOAPMessage message = smc.getMessage();
+ Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outboundProperty == true && this.isOutBoundHandlingEnabled() == false) {
+ return false;
+ }
+ if (outboundProperty == false && this.isInBoundHandlingEnabled() == false) {
+ return false;
+ }
+ if (smooksResource != null) {
+ try {
+ smc.setMessage(applySmooksTransformation(message));
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+
+ } else {
+ return false;
+ }
+
+ }
+
+ SOAPMessage applySmooksTransformation(SOAPMessage message) throws Exception {
+ ByteArrayOutputStream outStream = null;
+ ByteArrayInputStream inStream = null;
+
+ try {
+
+ ExecutionContext executionContext = smooks.createExecutionContext();
+ StringWriter transResult = new StringWriter();
+
+ BeanAccessor.getBeans(executionContext).putAll(this.beansMap);
+ StringWriter buffer;
+ outStream = new ByteArrayOutputStream();
+ message.writeTo(outStream);
+ outStream.flush();
+ inStream = new ByteArrayInputStream(outStream.toByteArray());
+ smooks.filter(new StreamSource(inStream), new StreamResult(transResult), executionContext);
+ inStream.close();
+ inStream = new ByteArrayInputStream(transResult.toString().getBytes());
+ SOAPMessage message2 = MessageFactory.newInstance().createMessage(message.getMimeHeaders(), inStream);
+ return message2;
+ } finally {
+ try {
+ inStream.close();
+ } catch (Exception e) {
+ // nop
+ }
+ try {
+ outStream.close();
+ } catch (Exception e) {
+ // nop
+ }
+ }
+ }
+
+ public boolean isOutBoundHandlingEnabled() {
+ return outBoundHandlingEnabled;
+ }
+
+ /**
+ *
+ * @param outBoundHandlingEnabled
+ * if true smooks transformation are applied to outBound
+ * message
+ */
+ public void setOutBoundHandlingEnabled(boolean outBoundHandlingEnabled) {
+ this.outBoundHandlingEnabled = outBoundHandlingEnabled;
+ }
+
+ public boolean isInBoundHandlingEnabled() {
+ return inBoundHandlingEnabled;
+ }
+
+ /**
+ *
+ * @param inBoundHandlingEnabled
+ * if true smooks transformation are applied to inBound
+ * message
+ */
+ public void setInBoundHandlingEnabled(boolean inBoundHandlingEnabled) {
+ this.inBoundHandlingEnabled = inBoundHandlingEnabled;
+ }
+}
Copied: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksMapper.java (from rev 25153, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksMapper.java)
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksMapper.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SmooksMapper.java 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,122 @@
+/**
+ * WISE Invokes Services Easily - Stefano Maestri / Alessio Soldano
+ *
+ * http://www.javalinuxlabs.org - http://www.javalinux.it
+ *
+ * Wise is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software Foundation;
+ * either version 2.1 of the License, or (at your option) any later version.
+ *
+ * Wise is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details at gnu.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import it.javalinux.wise.core.mapper.WiseMapper;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.xml.transform.Source;
+
+import org.milyn.Smooks;
+import org.milyn.container.ExecutionContext;
+import org.milyn.container.plugin.PayloadProcessor;
+import org.milyn.event.report.HtmlReportGenerator;
+import org.milyn.payload.JavaResult;
+import org.milyn.resource.URIResourceLocator;
+import org.xml.sax.SAXException;
+
+/**
+ * A WiseMapper based on smooks, copied from the wise codebase
+ *
+ * @author stefano.maestri at javalinux.it
+ *
+ */
+public class SmooksMapper implements WiseMapper {
+
+ private String smooksResource;
+
+ private String smooksReport ;
+
+ private final Smooks smooks ;
+
+ /**
+ * Create this mapper using passed resource
+ *
+ * @param smooksResource
+ * URI of smooks resource to use
+ * @throws SAXException
+ * @throws IOException
+ * @throws IllegalArgumentException
+ */
+ public SmooksMapper(String smooksResource)
+ throws IllegalArgumentException, IOException, SAXException {
+ this(smooksResource, null);
+ }
+
+ /**
+ * Create this mapper using passed resource and passed smooks html report to
+ * generate. A SmooksMapper created with this constructor will create an
+ * html smooks report useful for debug.
+ *
+ * @param smooksResource
+ * URI of smooks resource to use
+ * @param smooksReport
+ * the URI of smooks html report to generate.
+ * @throws SAXException
+ * @throws IllegalArgumentException
+ */
+ public SmooksMapper(String smooksResource, String smooksReport)
+ throws IOException, IllegalArgumentException, SAXException {
+ this.smooksResource = smooksResource;
+ this.smooksReport = smooksReport;
+ smooks = new Smooks();
+ smooks.addConfigurations("smooks-resource", new URIResourceLocator().getResource(smooksResource));
+ }
+
+ /**
+ * apply this mapping to original object
+ *
+ * @param originalObjects
+ * @return Map returned is typically used to invoke webservice operations.
+ * To do this, beanids defined in smooks config (and used here as
+ * Map's keys) have to be the parameters names as defined in
+ * wsdl/wsconsume generated classes
+ * @throws Exception
+ */
+ public Map<String, Object> applyMapping(Object originalObjects) throws Exception {
+
+ ExecutionContext executionContext = smooks.createExecutionContext();
+ Source source;
+ JavaResult result = new JavaResult();
+ // Configure the execution context to generate a report...
+ if (this.getSmooksReport() != null) {
+ executionContext.setEventListener(new HtmlReportGenerator(this.getSmooksReport()));
+ }
+ org.milyn.container.plugin.PayloadProcessor payloadProcessor = new PayloadProcessor(smooks, org.milyn.container.plugin.ResultType.JAVA);
+ // smooks should return a map
+ // TODO: verify with some unit tests
+ return (Map<String, Object>) payloadProcessor.process(originalObjects, executionContext);
+ // return result.getResultMap();
+
+ }
+
+ public String getSmooksResource() {
+ return smooksResource;
+ }
+
+ public void setSmooksResource(String smooksResource) {
+ this.smooksResource = smooksResource;
+ }
+
+ public String getSmooksReport() {
+ return smooksReport;
+ }
+
+ public void setSmooksReport(String smooksReport) {
+ this.smooksReport = smooksReport;
+ }
+
+}
Copied: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java (from rev 25153, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java)
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java 2009-02-09 10:48:33 UTC (rev 25155)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY 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
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import org.apache.commons.lang.StringUtils;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import sun.misc.BASE64Encoder;
+import it.javalinux.wise.core.client.WSDynamicClient;
+import it.javalinux.wise.core.exceptions.WiseConnectionException;
+import it.javalinux.wise.core.exceptions.WiseException;
+import it.javalinux.wise.core.utils.IDGenerator;
+import it.javalinux.wise.core.utils.IOUtils;
+import it.javalinux.wise.core.utils.WiseProperties;
+
+/**
+ * Factory for {@link WSDynamicClient}.
+ * Lifted from {@link it.javalinux.wise.core.client.WSDynamicClientFactory}.
+ * <p/>
+ */
+public class WSDynamicClientFactory
+{
+ private static final String WISE_PROPERTIES_FILE = "wise-core.properties";
+
+ private static final WSDynamicClientFactory SINGLETON = new WSDynamicClientFactory() ;
+
+ public static WSDynamicClientFactory getFactory()
+ {
+ return SINGLETON ;
+ }
+
+ public synchronized WSDynamicClient create(final String wsdl, final String name, final String username, final String password) throws WiseException
+ {
+ AssertArgument.isNotNull(name, "name");
+ AssertArgument.isNotNull(wsdl, "wsdl");
+
+ final WiseProperties wiseProperties = new WiseProperties(WISE_PROPERTIES_FILE);
+
+ String usableWsdl = wsdl;
+ if (wsdl.startsWith("http://"))
+ {
+ usableWsdl = downloadWsdl(wsdl, username, password, wiseProperties);
+ }
+
+ final WSDynamicClient client = new WSDynamicClient(wiseProperties);
+ client.init(usableWsdl, name, username, password);
+ return client;
+ }
+
+ private String downloadWsdl(String wsdlURL, String userName, String password, WiseProperties wiseProperties) throws WiseConnectionException
+ {
+ if (StringUtils.trimToNull(userName) == null || StringUtils.trimToNull(password) == null)
+ {
+ return this.transferWSDL(wsdlURL, null, wiseProperties);
+ }
+ else
+ {
+ return this.transferWSDL(wsdlURL, new StringBuffer(userName).append(":").append(password).toString(), wiseProperties);
+ }
+ }
+
+ private String transferWSDL(String wsdlURL, String userPassword, WiseProperties wiseProperties) throws WiseConnectionException
+ {
+ String filePath = null;
+ try
+ {
+ URL endpoint = new URL(wsdlURL);
+ // Create the connection
+ HttpURLConnection conn = (HttpURLConnection) endpoint.openConnection();
+ conn.setDoOutput(false);
+ conn.setDoInput(true);
+ conn.setUseCaches(false);
+ conn.setRequestMethod("GET");
+ conn.setRequestProperty("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
+ // set Connection close, otherwise we get a keep-alive
+ // connection
+ // that gives us fragmented answers.
+ conn.setRequestProperty("Connection", "close");
+ // BASIC AUTH
+ if (userPassword != null)
+ {
+ conn.setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode(userPassword.getBytes()));
+ }
+ // Read response
+ InputStream is = null;
+ if (conn.getResponseCode() == 200)
+ {
+ is = conn.getInputStream();
+ }
+ else
+ {
+ is = conn.getErrorStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ StringWriter sw = new StringWriter();
+ char[] buf = new char[200];
+ int read = 0;
+ while (read != -1)
+ {
+ read = isr.read(buf);
+ sw.write(buf);
+ }
+ throw new WiseConnectionException("Remote server's response is an error: " + sw.toString());
+ }
+ // saving file
+ File file = new File(wiseProperties.getProperty("wise.tmpDir"), new StringBuffer("Wise").append(IDGenerator.nextVal()).append(".xml").toString());
+ OutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
+ IOUtils.copyStream(fos, is);
+ fos.close();
+ is.close();
+ filePath = file.getPath();
+ }
+ catch (WiseConnectionException wce)
+ {
+ throw wce;
+ }
+ catch (Exception e)
+ {
+ throw new WiseConnectionException("Wsdl download failed!", e);
+ }
+ return filePath;
+ }
+}
\ No newline at end of file
Copied: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise (from rev 25153, labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise)
More information about the jboss-svn-commits
mailing list