You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2006/11/18 02:48:08 UTC
svn commit: r476410 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/marshaller/impl/
src/org/apache/axis2/jaxws/marshaller/impl/alt/
src/org/apache/axis2/jaxws/server/dispatcher/
test/org/apache/axis2/jaxws/provider/ test/o...
Author: scheu
Date: Fri Nov 17 17:48:07 2006
New Revision: 476410
URL: http://svn.apache.org/viewvc?view=rev&rev=476410
Log:
AXIS2-1743
Contributor: Mike Rheinheimer
2 Fixes: System Exception SOAPFault has a null reason text. JAX-WS Provider swallowing exceptions and returning empty message.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/string/StringProvider.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java?view=diff&rev=476410&r1=476409&r2=476410
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/MethodMarshallerImpl.java Fri Nov 17 17:48:07 2006
@@ -203,7 +203,6 @@
// If not found, this is a System Exception
FaultDescription fd = operationDesc.resolveFaultByExceptionName(t.getClass().getName());
- String text = null;
if (fd != null) {
// Service Exception. Create an XMLFault with the fault bean
Method getFaultInfo = t.getClass().getMethod("getFaultInfo", null);
@@ -220,12 +219,11 @@
faultBean.getClass(), faultBean, false);
}
detailBlocks[0] = createJAXBBlock(faultBean, context);
- text = t.getMessage();
- xmlfault = new XMLFault(null, new XMLFaultReason(text), detailBlocks);
+ xmlfault = new XMLFault(null, new XMLFaultReason(t.toString()), detailBlocks);
} else {
// System Exception
xmlfault = new XMLFault(null, // Use the default XMLFaultCode
- new XMLFaultReason(text)); // Assumes text is the language supported by the current Locale
+ new XMLFaultReason(t.toString())); // Assumes text is the language supported by the current Locale
}
// Add the fault to the message
message.setXMLFault(xmlfault);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?view=diff&rev=476410&r1=476409&r2=476410
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Fri Nov 17 17:48:07 2006
@@ -440,7 +440,6 @@
// If not found, this is a System Exception
FaultDescription fd = operationDesc.resolveFaultByExceptionName(t.getClass().getName());
- String text = null;
if (fd != null) {
// Service Exception.
@@ -458,12 +457,11 @@
detailBlocks[0] = factory.createFrom(faultBeanObject,context,null);
// Now make a XMLFault containing the detailblock
- text = t.getMessage();
- xmlfault = new XMLFault(null, new XMLFaultReason(text), detailBlocks);
+ xmlfault = new XMLFault(null, new XMLFaultReason(t.toString()), detailBlocks);
} else {
// System Exception
xmlfault = new XMLFault(null, // Use the default XMLFaultCode
- new XMLFaultReason(text)); // Assumes text is the language supported by the current Locale
+ new XMLFaultReason(t.toString())); // Assumes text is the language supported by the current Locale
}
// Add the fault to the message
message.setXMLFault(xmlfault);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?view=diff&rev=476410&r1=476409&r2=476410
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java Fri Nov 17 17:48:07 2006
@@ -19,7 +19,6 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.activation.DataSource;
@@ -41,6 +40,9 @@
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.XMLFault;
+import org.apache.axis2.jaxws.message.XMLFaultCode;
+import org.apache.axis2.jaxws.message.XMLFaultReason;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.factory.SOAPEnvelopeBlockFactory;
@@ -176,7 +178,8 @@
});
} catch (Exception e) {
e.printStackTrace();
- throw ExceptionFactory.makeWebServiceException(e);
+ //throw ExceptionFactory.makeWebServiceException(e);
+ responseParamValue = new XMLFault(XMLFaultCode.RECEIVER, new XMLFaultReason(e.toString()));
}
// If we have a one-way operation, then we cannot create a MessageContext
@@ -252,7 +255,12 @@
if (value != null) {
BlockFactory factory = createBlockFactory(providerType);
- if (providerServiceMode != null && providerServiceMode == Service.Mode.MESSAGE) {
+
+ if (value instanceof XMLFault) {
+ message = msgFactory.create(messageProtocol);
+ message.setXMLFault((XMLFault)value);
+ }
+ else if (providerServiceMode != null && providerServiceMode == Service.Mode.MESSAGE) {
// For MESSAGE mode, work with the entire message, Headers and Body
// This is based on logic in org.apache.axis2.jaxws.client.XMLDispatch.createMessageFromBundle()
if (value instanceof SOAPMessage) {
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java?view=diff&rev=476410&r1=476409&r2=476410
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProviderTests.java Fri Nov 17 17:48:07 2006
@@ -22,6 +22,7 @@
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
import org.apache.axis2.jaxws.dispatch.DispatchTestConstants;
@@ -44,6 +45,7 @@
}
public void testProviderString() throws Exception {
+
System.out.println("---------------------------------------");
System.out.println("test: " + getName());
@@ -56,6 +58,16 @@
System.out.println(">> Invoking Dispatch<String> StringProviderService");
String retVal = dispatch.invoke(xmlString);
System.out.println(">> Response [" + retVal + "]");
+ Exception ex = null;
+ try {
+ String re = dispatch.invoke("<invoke>throwException</invoke>");
+ } catch (Exception e) {
+ ex = e;
+ assertTrue(e instanceof WebServiceException);
+ String dfse = e.toString();
+ assertTrue(e.toString().equals("javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException: provider"));
+ }
+ assertNotNull(ex);
}
public void testSyncPayloadModeWithNull() throws Exception {
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/string/StringProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/string/StringProvider.java?view=diff&rev=476410&r1=476409&r2=476410
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/string/StringProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/string/StringProvider.java Fri Nov 17 17:48:07 2006
@@ -17,6 +17,7 @@
package org.apache.axis2.jaxws.provider.string;
import javax.xml.ws.Provider;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceProvider;
@WebServiceProvider()
@@ -27,6 +28,12 @@
public String invoke(String obj) {
if (obj != null) {
+
+ // TODO probably not the ideal place for a provider fault scenario test, but it serves its purpose
+ if (obj.equals("<invoke>throwException</invoke>")) {
+ throw new WebServiceException("provider");
+ }
+
String str = (String) obj;
System.out.println(">> StringProvider received a new request");
System.out.println(">> request [" + str + "]");
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java?view=diff&rev=476410&r1=476409&r2=476410
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java Fri Nov 17 17:48:07 2006
@@ -39,7 +39,7 @@
System.out.println("----------------------------------");
assertNotNull(exception);
- assertEquals("custom exception", exception.getMessage());
+ assertEquals("org.apache.axis2.jaxws.sample.faults.FaultyWebServiceFault_Exception: custom exception", exception.getMessage());
assertNotNull(exception.getFaultInfo());
assertEquals("bean custom fault info", exception.getFaultInfo().getFaultInfo());
assertEquals("bean custom message", exception.getFaultInfo().getMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org