[jboss-svn-commits] JBL Code SVN: r22739 - labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Sep 13 14:43:41 EDT 2008


Author: maeste
Date: 2008-09-13 14:43:41 -0400 (Sat, 13 Sep 2008)
New Revision: 22739

Modified:
   labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
Log:
JBESB-2037

Modified: labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java	2008-09-13 18:34:18 UTC (rev 22738)
+++ labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java	2008-09-13 18:43:41 UTC (rev 22739)
@@ -36,8 +36,8 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Logger;
 import javax.xml.ws.handler.Handler;
+import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
 import org.jboss.soa.esb.actions.ActionLifecycleException;
@@ -151,7 +151,7 @@
  */
 public class SOAPClient extends AbstractActionPipelineProcessor {
 
-    private final Logger logger = Logger.getLogger("SOAPClient");
+    private final Logger logger = Logger.getLogger(SOAPClient.class);
     private final String wsdl;
     private final String soapAction;
     private final String endPointName;
@@ -168,6 +168,14 @@
     private String smooksRequestReport = null;
     private String smooksResponseReport = null;
 
+    private InvocationResult result = null;
+
+    private WSMethod method = null;
+
+    private WiseMapper responseMapper = null;
+    private WiseMapper requestMapper = null;
+    private WSEndpoint endpoint;
+
     public SOAPClient( ConfigTree config ) throws ConfigurationException {
         wsdl = config.getRequiredAttribute("wsdl");
         soapAction = config.getRequiredAttribute("SOAPAction");
@@ -180,7 +188,9 @@
         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);
         ConfigTree[] handlersConfig;
         if (config.getAttribute("smooks-handler-config") != null) {
             smooksHandler.add(config.getAttribute("smooks-handler-config"));
@@ -201,9 +211,51 @@
     public void initialise() throws ActionLifecycleException {
         super.initialise();
         try {
-            WSDynamicClientFactory.getInstace().removeFromCache(serviceName);
-            SmooksCache.getInstance().remove(smooksRequestMapperURL);
-            SmooksCache.getInstance().remove(smooksResponseMapperURL);
+            WSDynamicClientFactory.getInstace().clearCache();
+            SmooksCache.getInstance().clear();
+            Object params;
+            WSDynamicClient client = null;
+            // get client from cache
+            try {
+                client = WSDynamicClientFactory.getInstace().getClient(wsdl, serviceName, username, password);
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new ActionProcessingException("Error durinfg wise client creation", e);
+            }
+
+            Map<String, WSEndpoint> endpointsMap = client.processEndpoints();
+            if (endPointName != null) {
+                endpoint = endpointsMap.get(endPointName);
+            } else {
+                endpoint = endpointsMap.values().iterator().next();
+            }
+
+            for (String config : customHandlers) {
+                logger.info("adding custom handler:" + config);
+                try {
+                    Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
+                    endpoint.addHandler((Handler)clazz.newInstance());
+                } catch (Exception e) {
+                    logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
+                }
+            }
+
+            if (loggingEnabled) {
+                logger.info("adding logging handler");
+                endpoint.addHandler(new LoggingHandler());
+            }
+
+            Map<String, WSMethod> wsmethodsMap = endpoint.getWSMethods();
+
+            if (this.smooksRequestMapperURL != null) {
+                requestMapper = new SmooksMapper(this.smooksRequestMapperURL, this.smooksRequestReport);
+            }
+            method = wsmethodsMap.get(this.soapAction);
+
+            if (this.smooksResponseMapperURL != null) {
+                responseMapper = new SmooksMapper(this.smooksResponseMapperURL, this.smooksResponseReport);
+            }
+
         } catch (Exception e) {
             throw new ActionLifecycleException("Error durinfg wise client cache cleaning", e);
         }
@@ -217,14 +269,6 @@
 
     public Message process( final Message message ) throws ActionProcessingException {
         Object params;
-        WSDynamicClient client = null;
-        // get client from cache
-        try {
-            client = WSDynamicClientFactory.getInstace().getClient(wsdl, serviceName, username, password);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new ActionProcessingException("Error durinfg wise client creation", e);
-        }
 
         try {
             params = payloadProxy.getPayload(message);
@@ -232,17 +276,6 @@
             throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
         }
 
-        // if (params.isEmpty()) {
-        // logger.warn("Params Map found in message, but the map is empty.");
-        // }
-        Map<String, WSEndpoint> endpointsMap = client.processEndpoints();
-        WSEndpoint endpoint;
-        if (endPointName != null) {
-            endpoint = endpointsMap.get(endPointName);
-        } else {
-            endpoint = endpointsMap.values().iterator().next();
-        }
-
         for (String config : smooksHandler) {
             logger.info("adding smooks handler:" + config);
             if (params instanceof Map) {
@@ -252,42 +285,15 @@
             }
         }
 
-        for (String config : customHandlers) {
-            logger.info("adding custom handler:" + config);
-            try {
-                Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
-                endpoint.addHandler((Handler)clazz.newInstance());
-            } catch (Exception e) {
-                logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
-            }
-        }
-
-        if (loggingEnabled) {
-            logger.info("adding logging handler");
-            endpoint.addHandler(new LoggingHandler());
-        }
-
-        Map<String, WSMethod> wsmethodsMap = endpoint.getWSMethods();
-
-        InvocationResult result;
         try {
-            WiseMapper mapper = null;
-            if (this.smooksRequestMapperURL != null) {
-                mapper = new SmooksMapper(this.smooksRequestMapperURL, this.smooksRequestReport);
-            }
-            result = wsmethodsMap.get(this.soapAction).invoke(params, mapper);
+            result = method.invoke(params, requestMapper);
         } catch (WiseException e) {
             throw new ActionProcessingException("Could not call method" + this.soapAction, e);
         }
 
-        WiseMapper mapper = null;
-        if (this.smooksResponseMapperURL != null) {
-            mapper = new SmooksMapper(this.smooksResponseMapperURL, this.smooksResponseReport);
-        }
-        // And process the response into the message...
-
         try {
-            Map map = result.getMappedResult(mapper, (Map)params);
+            Map map = result.getMappedResult(responseMapper, (Map)params);
+            logger.info("map = " + map);
             payloadProxy.setPayload(message, map);
         } catch (Exception e) {
             throw new ActionProcessingException("Could not set payload to SOAP message", e);




More information about the jboss-svn-commits mailing list