[jboss-svn-commits] JBL Code SVN: r37426 - in labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap: aop/resources/META-INF and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Aug 22 15:32:18 EDT 2011
Author: tcunning
Date: 2011-08-22 15:32:17 -0400 (Mon, 22 Aug 2011)
New Revision: 37426
Added:
labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/java/org/jboss/internal/soa/esb/soap/wise/WSMethodInvokeAspect.java
Modified:
labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/resources/META-INF/jboss-aop.xml
labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
Log:
JBESB-3643
Checking in one-off fix for SOAPClient Exception loss.
Added: labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/java/org/jboss/internal/soa/esb/soap/wise/WSMethodInvokeAspect.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/java/org/jboss/internal/soa/esb/soap/wise/WSMethodInvokeAspect.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/java/org/jboss/internal/soa/esb/soap/wise/WSMethodInvokeAspect.java 2011-08-22 19:32:17 UTC (rev 37426)
@@ -0,0 +1,76 @@
+package org.jboss.internal.soa.esb.soap.wise;
+
+import it.javalinux.wise.core.client.InvocationResult;
+import it.javalinux.wise.core.client.WSEndpoint;
+import it.javalinux.wise.core.client.WSMethod;
+import it.javalinux.wise.core.mapper.WiseMapper;
+import it.javalinux.wise.core.exceptions.WiseException;
+
+import java.util.Map;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+
+/**
+ * WISE should process valid SOAPFaultExceptions - this aspect will rethrow a InvocationTargetException
+ * as a WiseException with the InvocationTargetException as the cause. This exception can then
+ * be processed as a valid response in SOAPClient.
+ *
+ * @author tcunning
+ */
+public class WSMethodInvokeAspect {
+ public InvocationResult invoke(final MethodInvocation invocation) throws WiseException
+ {
+ final Object[] invocationArgs = invocation.getArguments() ;
+ final Object args = invocationArgs[0];
+ final WiseMapper mapper = (WiseMapper) invocationArgs[1];
+
+ final WSMethod wsMethod = (WSMethod)invocation.getTargetObject();
+
+ boolean continueOnSOAPFault = Boolean.parseBoolean(System.getProperty("ContinueOnSOAPFault"));
+ if (!continueOnSOAPFault) {
+ try {
+ return (InvocationResult) invocation.invokeNext();
+ } catch (Throwable t) {
+ throw new WiseException("Unknown Exception " + t);
+ }
+ }
+
+ if (mapper == null) {
+ try {
+ return (InvocationResult) invocation.invokeNext();
+ } catch (WiseException we) {
+ throw we;
+ } catch (Throwable t) {
+ throw new WiseException("Unknown Exception " + t);
+ }
+ }
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Map mappingResults;
+ try {
+ WSEndpoint wsEndpoint = wsMethod.getEndpoint();
+ Thread.currentThread().setContextClassLoader(wsEndpoint.getClassLoader());
+ mappingResults = mapper.applyMapping(args);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
+ // Set the arguments, with the mapper set to null, so that we call the no-mapper upon reinvocation
+ Object tempArgs[] = new Object[2];
+ tempArgs[0] = args;
+ tempArgs[1] = null;
+ invocation.setArguments(tempArgs);
+ return (InvocationResult) invocation.invokeNext();
+ } catch (InvocationTargetException ite) {
+ WiseException.rethrow("Unknown exception received: " + ite.getMessage(), ite);
+ } catch (WiseException e) {
+ WiseException.rethrow("Unknown exception received: " + e.getCause().getMessage(), e.getCause());
+ } catch (Throwable t) {
+ WiseException.rethrow("Unknown exception received: " + t.toString(), t);
+ }
+
+ throw new WiseException("Transformation Failed");
+ }
+}
Modified: labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/resources/META-INF/jboss-aop.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/resources/META-INF/jboss-aop.xml 2011-08-18 18:06:00 UTC (rev 37425)
+++ labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/aop/resources/META-INF/jboss-aop.xml 2011-08-22 19:32:17 UTC (rev 37426)
@@ -5,7 +5,8 @@
<aspect class="org.jboss.internal.soa.esb.soap.wise.WSMethodIsOneWayAspect" scope="PER_VM"/>
<aspect class="org.jboss.internal.soa.esb.soap.ws.CompilerAspect" scope="PER_VM"/>
<aspect class="org.jboss.internal.soa.esb.soap.wise.WSDynamicClientEndpointsAspect" scope="PER_VM"/>
-
+ <aspect class="org.jboss.internal.soa.esb.soap.wise.WSMethodInvokeAspect" scope="PER_VM"/>
+
<bind pointcut="execution(* it.javalinux.wise.core.client.WSMethod->getParmeterInRightPositionArray(..))">
<advice name="getParameterInRightPositionArray" aspect="org.jboss.internal.soa.esb.soap.wise.WSMethodParameterMappingAspect"/>
</bind>
@@ -13,6 +14,10 @@
<bind pointcut="execution(* it.javalinux.wise.core.client.WSMethod->getHoldersResult(..))">
<advice name="getHoldersResult" aspect="org.jboss.internal.soa.esb.soap.wise.WSMethodParameterMappingAspect"/>
</bind>
+
+ <bind pointcut="execution(* it.javalinux.wise.core.client.WSMethod->invoke(java.lang.Object, it.javalinux.wise.core.mapper.WiseMapper))">
+ <advice name="invoke" aspect="org.jboss.internal.soa.esb.soap.wise.WSMethodInvokeAspect"/>
+ </bind>
<bind pointcut="execution(* it.javalinux.wise.core.client.WSDynamicClient->defineAdditionalCompilerClassPath(..))">
<advice name="defineAdditionalCompilerClassPath" aspect="org.jboss.internal.soa.esb.soap.wise.WSDynamicClientClasspathAspect"/>
Modified: labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2011-08-18 18:06:00 UTC (rev 37425)
+++ labs/jbossesb/branches/JBESB_4_10_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2011-08-22 19:32:17 UTC (rev 37426)
@@ -30,6 +30,8 @@
import it.javalinux.wise.core.exceptions.WiseException;
import it.javalinux.wise.core.mapper.WiseMapper;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -37,6 +39,7 @@
import javax.jws.Oneway;
import javax.xml.ws.handler.Handler;
+import javax.xml.ws.soap.SOAPFaultException;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.publish.Publish;
@@ -154,6 +157,11 @@
* <property name="LoggingMessages" value="true" />
* </pre>
*
+ * Continuing on SOAPFaultException
+ * <pre>
+ * <property name="ContinueOnSOAPFault" value="true" />
+ * </pre>
+ *
* @author <a href="mailto:stefano.maestri at javalinux.it">stefano.maestri at javalinux.it</a>
*/
@Publish(WiseWsdlContractPublisher.class)
@@ -175,6 +183,7 @@
private final List<String> customHandlers = new ArrayList<String>();
private final MessagePayloadProxy payloadProxy;
private boolean loggingEnabled = false;
+ private boolean continueOnSOAPFault = false;
private WSDynamicClient client;
@@ -192,6 +201,8 @@
username = config.getAttribute("username");
password = config.getAttribute("password");
loggingEnabled = Boolean.parseBoolean(config.getAttribute("LoggingMessages"));
+ continueOnSOAPFault = Boolean.parseBoolean(config.getAttribute("ContinueOnSOAPFault"));
+
logger.debug("loggingEnabled:" + loggingEnabled);
if (config.getAttribute("smooks-handler-config") != null)
@@ -241,19 +252,44 @@
Object payload = getMessagePayload(message);
final List<SmooksHandler> handlers = addSmooksHandlers(endpoint, payload);
try
- {
+ {
addCustomHandlers(endpoint);
addLoggingHandler(endpoint);
WSMethod wsMethod = getWSMethodFromEndpoint(operationName, endpoint);
-
+
InvocationResult result;
try
{
+ System.setProperty("ContinueOnSOAPFault", "" + continueOnSOAPFault);
result = wsMethod.invoke(payload, smooksRequestMapper);
}
catch (final WiseException e)
{
+ if (e.getCause() != null) {
+ if (e.getCause() instanceof InvocationTargetException) {
+ Map emptyHolder = Collections.emptyMap();
+
+ Object epInstance = wsMethod.getEndpoint().getInstance();
+ Method methodPointer;
+ try {
+ methodPointer = epInstance.getClass().getMethod(wsMethod.getMethod().getName(), (Class[])wsMethod.getMethod().getParameterTypes());
+ } catch (SecurityException e1) {
+ throw new ActionProcessingException("Security Exception when trying to obtain methodPointer for "
+ + wsMethod.getMethod().getName(), e1);
+ } catch (NoSuchMethodException e1) {
+ throw new ActionProcessingException("NoSuchMethodException thrown when trying to obtain methodPointer for "
+ + wsMethod.getMethod().getName(), e1);
+ }
+
+ InvocationTargetException ite = (InvocationTargetException) e.getCause();
+ if (ite.getTargetException() instanceof SOAPFaultException) {
+ result = new InvocationResult("exception", ite.getTargetException(), emptyHolder);
+ return mapResponseToMessage(message, result, smooksResponseMapper);
+ }
+ }
+ }
+
if (logger.isDebugEnabled())
{
logger.debug("Exception thrown from wsMethod invocation", e) ;
More information about the jboss-svn-commits
mailing list