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/10 03:09:14 UTC
svn commit: r473168 [1/2] - in /webservices/axis2/trunk/java/modules/jaxws:
./ src/org/apache/axis2/jaxws/ src/org/apache/axis2/jaxws/i18n/
src/org/apache/axis2/jaxws/marshaller/
src/org/apache/axis2/jaxws/marshaller/impl/ src/org/apache/axis2/jaxws/me...
Author: scheu
Date: Thu Nov 9 18:09:13 2006
New Revision: 473168
URL: http://svn.apache.org/viewvc?view=rev&rev=473168
Log:
AXIS2-956
Contributor:Rich Scheuerle, Min Zheng, Mike Rheinheimer
Added code to MethodMarshaller to prevent non-WebServiceExceptions from being thrown.
Improvements to Fault handling code
Added (and disabled) polymorphic fault service test
Added:
webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/FaultsService.wsdl
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/BaseFault_Exception.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/ComplexFault_Exception.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/DerivedFault1_Exception.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/DerivedFault2_Exception.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/EqualFault.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsService.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServicePortType.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServiceSoapBindingImpl.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/META-INF/
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/SimpleFault.java
Removed:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MarshalException.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/UnmarshalException.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/maven.xml
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
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/message/databinding/JAXBBlockContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/maven.xml?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws/maven.xml Thu Nov 9 18:09:13 2006
@@ -91,6 +91,13 @@
<classpath refid="maven.dependency.classpath"/>
<classpath location="${compiled.classes.dir}"/>
<arg line="-d ${schema.generated.src.dir} -wsdl ${wsdl.source.dir}/FaultyWebService.wsdl"/>
+ </java>
+ <ant:echo>Generating java from FaultsService.wsdl</ant:echo>
+ <java classname="com.sun.tools.xjc.Driver" fork="true">
+ <jvmarg line="${maven.junit.jvmargs}"/>
+ <classpath refid="maven.dependency.classpath"/>
+ <classpath location="${compiled.classes.dir}"/>
+ <arg line="-d ${schema.generated.src.dir} -wsdl ${wsdl.source.dir}/FaultsService.wsdl"/>
</java>
<ant:echo>Generating java from jaxbsource</ant:echo>
<java classname="com.sun.tools.xjc.Driver" fork="true">
@@ -337,6 +344,17 @@
<ant:include name="org/apache/axis2/jaxws/sample/faults/**"/>
</ant:fileset>
<ant:fileset dir="test/org/apache/axis2/jaxws/sample/faults">
+ <ant:include name="META-INF/**"/>
+ </ant:fileset>
+ <ant:fileset dir="target/classes">
+ <ant:include name="org/apache/axis2/jaxws/server/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <ant:copy toDir="target/test-classes/services/FaultsService/">
+ <ant:fileset dir="target/test-classes">
+ <ant:include name="org/apache/axis2/jaxws/sample/faultsservice/**"/>
+ </ant:fileset>
+ <ant:fileset dir="test/org/apache/axis2/jaxws/sample/faultsservice">
<ant:include name="META-INF/**"/>
</ant:fileset>
<ant:fileset dir="target/classes">
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java Thu Nov 9 18:09:13 2006
@@ -213,13 +213,14 @@
Throwable rootCause = null;
if (t != null) {
rootCause = getRootCause(t);
- }
-
- WebServiceException e;
- if (rootCause != null)
- e = new WebServiceException(rootCause.getMessage(), rootCause);
- else
- e = new WebServiceException(message, t);
+ }
+ rootCause = rootCause==null ? t :rootCause;
+ WebServiceException e = null;
+ if (message != null) {
+ e =new WebServiceException(message, rootCause);
+ } else {
+ e = new WebServiceException(rootCause);
+ }
if (log.isDebugEnabled()) {
log.debug("Create Exception:", e);
@@ -238,9 +239,15 @@
if (t != null) {
rootCause = getRootCause(t);
}
- ProtocolException e = new ProtocolException(message, t);
+ rootCause = rootCause==null ? t :rootCause;
+ ProtocolException e = null;
+ if (message != null) {
+ e = new ProtocolException(message, rootCause);
+ } else {
+ e = new ProtocolException(rootCause);
+ }
if (log.isDebugEnabled()) {
- log.debug("create Exception:", t);
+ log.debug("create Exception:", e);
}
return e;
}
@@ -256,9 +263,16 @@
if (t != null) {
rootCause = getRootCause(t);
}
- MessageException e = new MessageException(message, t);
+ rootCause = rootCause==null ? t :rootCause;
+
+ MessageException e = null;
+ if (message != null) {
+ e = new MessageException(message, rootCause);
+ } else {
+ e = new MessageException(rootCause);
+ }
if (log.isDebugEnabled()) {
- log.debug("create Exception:", t);
+ log.debug("create Exception:", e);
}
return e;
}
@@ -274,9 +288,16 @@
if (t != null) {
rootCause = getRootCause(t);
}
- MessageInternalException e = new MessageInternalException(message, t);
+ rootCause = rootCause==null ? t :rootCause;
+
+ MessageInternalException e = null;
+ if (message != null) {
+ e = new MessageInternalException(message, rootCause);
+ } else {
+ e = new MessageInternalException(rootCause);
+ }
if (log.isDebugEnabled()) {
- log.debug("create Exception:", t);
+ log.debug("create Exception:", e);
}
return e;
}
@@ -332,6 +353,8 @@
while (t != null) {
Throwable nextCause = null;
if (t instanceof InvocationTargetException ||
+ t instanceof MessageException ||
+ t instanceof MessageInternalException ||
t instanceof AxisFault) {
// Skip over this cause
nextCause = getCause(t);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties Thu Nov 9 18:09:13 2006
@@ -129,8 +129,9 @@
ResourceInjectionFactoryErr1=Unknown Resource Type, Currently only Resource of Type javax.xml.ws.WebServiceContext can be injected.
EndpointLifecycleManagerImplErr1=Failed to create EndpointLifecycleManager, Endpoint Instance cannot be null.
ClassUtilsErr1=Unable to get class loader.
-ClassUtilsErr2={0} + " does not appear to be a valid package (Unsupported encoding)"
-ClassUtilsErr3="IOException was thrown when trying to get all resources for {0}"
+ClassUtilsErr2={0} does not appear to be a valid package (Unsupported encoding)
+ClassUtilsErr3="IOException was thrown when trying to get all resources for {0}
ClassUtilsErr1=Unable to get class loader.
-ClassUtilsErr2={0} + " does not appear to be a valid package (Unsupported encoding)"
-ClassUtilsErr3="IOException was thrown when trying to get all resources for {0}"
+ClassUtilsErr2={0} does not appear to be a valid package (Unsupported encoding)
+ClassUtilsErr3=IOException was thrown when trying to get all resources for {0}
+MethodMarshallerErr1=Cannot create a custom JAX-WS exception for fault bean: {0}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/MethodMarshaller.java Thu Nov 9 18:09:13 2006
@@ -18,11 +18,15 @@
*/
package org.apache.axis2.jaxws.marshaller;
+import javax.xml.ws.WebServiceException;
+
import org.apache.axis2.jaxws.message.Message;
/**
- * This is a helper class that converts org.apache.axis2.jaxws.message.Message to java Objects
- * or JAXBObject. It also converts java objects or JAXBObject to org.apache.axis2.jaxws.message.Message.
+ * This class marshals and unmarshals method invocations.
+ *
+ * If there are any problems, a WebServiceException is thrown. (Each of the methods is guranteed to catch any unchecked exception and wrap
+ * it in a WebServiceException).
*/
public interface MethodMarshaller {
@@ -42,7 +46,7 @@
* @param object
* @return
*/
- public Message marshalRequest(Object[] object) throws MarshalException;
+ public Message marshalRequest(Object[] object) throws WebServiceException;
/**
* This method creates Message from a returnObject and input parameters of holder type. This is a case where we have method with return
@@ -50,7 +54,7 @@
* @param jaxbObject
* @return
*/
- public Message marshalResponse(Object returnObject, Object[] holderObjects)throws MarshalException;
+ public Message marshalResponse(Object returnObject, Object[] holderObjects)throws WebServiceException;
/**
* This method creates Fault Message from a Throbale input parameter.
@@ -58,14 +62,14 @@
* @param jaxbObject
* @return
*/
- public Message marshalFaultResponse(Throwable throwable) throws MarshalException;
+ public Message marshalFaultResponse(Throwable throwable) throws WebServiceException;
/**
* This method converts Message to java objects. Used on Server Side to this extract method input parameters from message and invokes method on service
* with found input parameters on ServiceEndpoint.
* @param message
* @return
*/
- public Object[] demarshalRequest(Message message)throws UnmarshalException;
+ public Object[] demarshalRequest(Message message)throws WebServiceException;
/**
* This method converts Message to Object. Used on Client side when converting response message from Server to ResponseWrapper/return type of method that
@@ -83,14 +87,14 @@
* @param message
* @return
*/
- public Object demarshalResponse(Message message, Object[] inputArgs) throws UnmarshalException;
+ public Object demarshalResponse(Message message, Object[] inputArgs) throws WebServiceException;
/**
* This method converts Fault Message to fault java objects. Used on Client Side to extract Fault Object expected by client from message.
* @param message
* @return
*/
- public Object demarshalFaultResponse(Message message) throws UnmarshalException;
+ public Object demarshalFaultResponse(Message message) throws WebServiceException;
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitBareMethodMarshallerImpl.java Thu Nov 9 18:09:13 2006
@@ -22,6 +22,7 @@
import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.WebServiceException;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -30,9 +31,7 @@
import org.apache.axis2.jaxws.description.ServiceDescription;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.marshaller.DocLitBareMethodMarshaller;
-import org.apache.axis2.jaxws.marshaller.MarshalException;
import org.apache.axis2.jaxws.marshaller.MethodParameter;
-import org.apache.axis2.jaxws.marshaller.UnmarshalException;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.Protocol;
@@ -58,112 +57,103 @@
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toJAXBObject(org.apache.axis2.jaxws.message.Message)
*/
@Override
- public Object demarshalResponse(Message message, Object[] inputArgs) throws UnmarshalException {
- Class returnType = getReturnType();
-
- ArrayList<Object> holderArgs = null;
- ArrayList<MethodParameter> mps = null;
- ArrayList<MethodParameter> holdermps = null;
- try {
- holderArgs = new ArrayList<Object>();
- mps = new ArrayList<MethodParameter>();
- mps = extractHolderParameters(inputArgs);
- holdermps = new ArrayList<MethodParameter>(mps);
- } catch (IllegalAccessException e) {
- throw new UnmarshalException("Unable to get holder method parameters", e);
- } catch (InstantiationException e) {
- throw new UnmarshalException("Unable to get holder method parameters", e);
- } catch (ClassNotFoundException e) {
- throw new UnmarshalException("Unable to get holder method parameters", e);
- }
-
- // Remove everything except holders from input arguments.
- int index = 0;
- for(Object inputArg: inputArgs){
- if(inputArg !=null && isHolder(inputArg)){
- holderArgs.add(inputArg);
+ public Object demarshalResponse(Message message, Object[] inputArgs) throws WebServiceException {
+ try {
+
+ Class returnType = getReturnType();
+
+ ArrayList<Object> holderArgs = null;
+ ArrayList<MethodParameter> mps = null;
+ ArrayList<MethodParameter> holdermps = null;
+
+ holderArgs = new ArrayList<Object>();
+ mps = new ArrayList<MethodParameter>();
+ mps = extractHolderParameters(inputArgs);
+ holdermps = new ArrayList<MethodParameter>(mps);
+
+
+ // Remove everything except holders from input arguments.
+ int index = 0;
+ for(Object inputArg: inputArgs){
+ if(inputArg !=null && isHolder(inputArg)){
+ holderArgs.add(inputArg);
+ }
+ index++;
}
- index++;
- }
-
- try {
- if(holdermps.size() == 0 && returnType.getName().equals("void")){
- // No holders and return type void example --> public void someMethod()
- // I will return null for this case.
- // doNothing as there is nothing to return.
- return null;
- }
- else if(holdermps.size() == 0 && !returnType.getName().equals("void")){
- // No holders but a return type example --> public ReturnType someMethod()
- Object bo = createBusinessObject(returnType, message);
- return bo;
- }
- else if(holdermps.size()>0 && returnType.getName().equals("void")){
- // Holders found and no return type example --> public void someMethod(Holder<AHolder>)
- assignHolderValues(holdermps, holderArgs, message);
- }
- else{
- // Holders found and return type example --> public ReturnType someMethod(Holder<AHolder>)
- // Note that SEI implementation will wrap return type in a holder if method has a return
- // type and input param as holder.
- // WSGen and WsImport Generate Holders with return type as one of the Holder JAXBObject
- // property, if wsdl schema forces a holder and a return type.
- assignHolderValues(holdermps, holderArgs, message);
- Object bo = createBusinessObject(returnType, message);
- return bo;
- }
- } catch (JAXBException e) {
- throw new UnmarshalException("Unable to demarshal response", e);
- } catch (MessageException e) {
- throw new UnmarshalException("Unable to demarshal response", e);
- } catch (XMLStreamException e) {
- throw new UnmarshalException("Unable to demarshal response", e);
- }
- return null;
+
+ if(holdermps.size() == 0 && returnType.getName().equals("void")){
+ // No holders and return type void example --> public void someMethod()
+ // I will return null for this case.
+ // doNothing as there is nothing to return.
+ return null;
+ }
+ else if(holdermps.size() == 0 && !returnType.getName().equals("void")){
+ // No holders but a return type example --> public ReturnType someMethod()
+ Object bo = createBusinessObject(returnType, message);
+ return bo;
+ }
+ else if(holdermps.size()>0 && returnType.getName().equals("void")){
+ // Holders found and no return type example --> public void someMethod(Holder<AHolder>)
+ assignHolderValues(holdermps, holderArgs, message);
+ }
+ else{
+ // Holders found and return type example --> public ReturnType someMethod(Holder<AHolder>)
+ // Note that SEI implementation will wrap return type in a holder if method has a return
+ // type and input param as holder.
+ // WSGen and WsImport Generate Holders with return type as one of the Holder JAXBObject
+ // property, if wsdl schema forces a holder and a return type.
+ assignHolderValues(holdermps, holderArgs, message);
+ Object bo = createBusinessObject(returnType, message);
+ return bo;
+ }
+
+
+ return null;
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
}
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toObjects(org.apache.axis2.jaxws.message.Message)
*/
@Override
- public Object[] demarshalRequest(Message message) throws UnmarshalException {
- if (log.isDebugEnabled()) {
- log.debug("Attempting to demarshal a document/literal request.");
- }
-
- ArrayList<Class> inputParams = getInputTypes();
-
- // If the method has no input parameters, then we're done.
- if(inputParams.size() == 0){
- return null;
- }
-
- ArrayList<MethodParameter> mps;
- try {
- mps = createParameterForSEIMethod(message);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("An error occured while demarshalling the request" + e.getMessage());
- }
- throw new UnmarshalException("Unable to demarshal the request message.", e);
- }
-
- ArrayList<Object> objectList = new ArrayList<Object>();
- if (log.isDebugEnabled()) {
- log.debug("reading input method parameters");
- }
- for(MethodParameter mp:mps){
- ParameterDescription pd = mp.getParameterDescription();
- if(pd.isHolderType()){
- Object holderObject = mp.getValue();
- objectList.add(holderObject);
- }
- else{
- objectList.add(mp.getValue());
- }
+ public Object[] demarshalRequest(Message message) throws WebServiceException {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Attempting to demarshal a document/literal request.");
+ }
+
+ ArrayList<Class> inputParams = getInputTypes();
+
+ // If the method has no input parameters, then we're done.
+ if(inputParams.size() == 0){
+ return null;
+ }
+
+ ArrayList<MethodParameter> mps = createParameterForSEIMethod(message);
+
+ ArrayList<Object> objectList = new ArrayList<Object>();
+ if (log.isDebugEnabled()) {
+ log.debug("reading input method parameters");
+ }
+ for(MethodParameter mp:mps){
+ ParameterDescription pd = mp.getParameterDescription();
+ if(pd.isHolderType()){
+ Object holderObject = mp.getValue();
+ objectList.add(holderObject);
+ }
+ else{
+ objectList.add(mp.getValue());
+ }
+ }
+ return objectList.toArray();
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
}
- return objectList.toArray();
}
/*
@@ -171,62 +161,53 @@
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromJAXBObject(java.lang.Object)
*/
@Override
- public Message marshalResponse(Object returnObject, Object[] holderObjects) throws MarshalException {
- // Response wrapper is basically the return type. So the return object
- // is a JAXB object. If there is a holder objects then that is the
- // responsewrapper.
- Class wrapperClazz = getReturnType();
- String wrapperClazzName = operationDesc.getResultName();
- if (wrapperClazzName == null || wrapperClazzName.trim().length() == 0) {
- wrapperClazzName = wrapperClazz.getName();
- }
- String wrapperTNS = operationDesc.getResultTargetNamespace();
-
- ArrayList<MethodParameter> holdersNreturnObject;
- try {
- holdersNreturnObject = extractHolderParameters(holderObjects);
- } catch (IllegalAccessException e) {
- throw new MarshalException("Unable to extract holder params", e);
- } catch (InstantiationException e) {
- throw new MarshalException("Unable to extract holder params", e);
- } catch (ClassNotFoundException e) {
- throw new MarshalException("Unable to extract holder params", e);
- }
-
- Message message = null;
+ public Message marshalResponse(Object returnObject, Object[] holderObjects) throws WebServiceException {
try {
- if(holdersNreturnObject.size() == 0 && wrapperClazz.getName().equals("void")){
- //No holders and return type void example --> public void someMethod() I will return empty ResponseWrapper in message body for this case.
- //doNothing as there is nothing to wrap
- message = createEmptyMessage();
- }
- else if(holdersNreturnObject.size() == 0 && !wrapperClazz.getName().equals("void")){
- //No holders but a return type example --> public ReturnType someMethod()
- MethodParameter mp = new MethodParameter(wrapperClazzName,wrapperTNS, wrapperClazz, returnObject);
- holdersNreturnObject.add(mp);
- message = createMessage(holdersNreturnObject);
- }
- else if(holdersNreturnObject.size()>0 && wrapperClazz.getName().equals("void")){
- //Holders found and no return type example --> public void someMethod(Holder<AHolder>)
- message = createMessage(holdersNreturnObject);
- }
- else{
- //Holders found and return type example --> public ReturnType someMethod(Holder<AHolder>)
- //Note that SEI implementation will wrap return type in a holder if method has a return type and input param as holder.
- //WSGen and WsImport Generate Holders with return type as one of the Holder JAXBObject property, if wsdl schema forces a holder and a return type.
- MethodParameter mp = new MethodParameter(wrapperClazzName,wrapperTNS, wrapperClazz, returnObject);
- holdersNreturnObject.add(mp);
- message = createMessage(holdersNreturnObject);
- }
- } catch (JAXBException e) {
- throw new MarshalException("An error occured while marshalling the response message.", e);
- } catch (MessageException e) {
- throw new MarshalException("An error occured while marshalling the response message.", e);
- } catch (XMLStreamException e) {
- throw new MarshalException("An error occured while marshalling the response message.", e);
- }
-
- return message;
+ // Response wrapper is basically the return type. So the return object
+ // is a JAXB object. If there is a holder objects then that is the
+ // responsewrapper.
+ Class wrapperClazz = getReturnType();
+ String wrapperClazzName = operationDesc.getResultName();
+ if (wrapperClazzName == null || wrapperClazzName.trim().length() == 0) {
+ wrapperClazzName = wrapperClazz.getName();
+ }
+ String wrapperTNS = operationDesc.getResultTargetNamespace();
+
+ ArrayList<MethodParameter> holdersNreturnObject = extractHolderParameters(holderObjects);
+
+
+ Message message = null;
+
+ if(holdersNreturnObject.size() == 0 && wrapperClazz.getName().equals("void")){
+ //No holders and return type void example --> public void someMethod() I will return empty ResponseWrapper in message body for this case.
+ //doNothing as there is nothing to wrap
+ message = createEmptyMessage();
+ }
+ else if(holdersNreturnObject.size() == 0 && !wrapperClazz.getName().equals("void")){
+ //No holders but a return type example --> public ReturnType someMethod()
+ MethodParameter mp = new MethodParameter(wrapperClazzName,wrapperTNS, wrapperClazz, returnObject);
+ holdersNreturnObject.add(mp);
+ message = createMessage(holdersNreturnObject);
+ }
+ else if(holdersNreturnObject.size()>0 && wrapperClazz.getName().equals("void")){
+ //Holders found and no return type example --> public void someMethod(Holder<AHolder>)
+ message = createMessage(holdersNreturnObject);
+ }
+ else{
+ //Holders found and return type example --> public ReturnType someMethod(Holder<AHolder>)
+ //Note that SEI implementation will wrap return type in a holder if method has a return type and input param as holder.
+ //WSGen and WsImport Generate Holders with return type as one of the Holder JAXBObject property, if wsdl schema forces a holder and a return type.
+ MethodParameter mp = new MethodParameter(wrapperClazzName,wrapperTNS, wrapperClazz, returnObject);
+ holdersNreturnObject.add(mp);
+ message = createMessage(holdersNreturnObject);
+ }
+
+
+ return message;
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
}
/*
@@ -234,60 +215,50 @@
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromObjects(java.lang.Object[])
*/
@Override
- public Message marshalRequest(Object[] objects) throws MarshalException {
- if (log.isDebugEnabled()) {
- log.debug("Attempting to marshal document/literal request");
- }
-
- ArrayList<MethodParameter> mps = null;
- try {
- mps = createRequestWrapperParameters(objects);
- } catch (IllegalAccessException e) {
- throw new MarshalException("Unable to create request wrapper parameters", e);
- } catch (InstantiationException e) {
- throw new MarshalException("Unable to create request wrapper parameters", e);
- } catch (ClassNotFoundException e) {
- throw new MarshalException("Unable to create request wrapper parameters", e);
- }
-
-
- //WSDL wrapped and running wsImport with non-wrap binding or wsdl un-Wrapped and running wsImport with no binding, EITHER WAYS
- //there can be only 0 or 1 Body parts as per WS-I.
- if(mps.size()> SIZE){
- int numberOfBodyPart =0;
- for(MethodParameter mp:mps){
- ParameterDescription pd = mp.getParameterDescription();
- if(!pd.isHeader()){
- numberOfBodyPart++;
+ public Message marshalRequest(Object[] objects) throws WebServiceException {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Attempting to marshal document/literal request");
+ }
+
+ ArrayList<MethodParameter> mps = createRequestWrapperParameters(objects);
+
+ //WSDL wrapped and running wsImport with non-wrap binding or wsdl un-Wrapped and running wsImport with no binding, EITHER WAYS
+ //there can be only 0 or 1 Body parts as per WS-I.
+ if(mps.size()> SIZE){
+ int numberOfBodyPart =0;
+ for(MethodParameter mp:mps){
+ ParameterDescription pd = mp.getParameterDescription();
+ if(!pd.isHeader()){
+ numberOfBodyPart++;
+ }
+ }
+ if(numberOfBodyPart > SIZE){
+ if (log.isDebugEnabled()) {
+ log.debug("As per WS-I compliance, Multi part WSDL with more than one body part not allowed for Doc/Lit NON Wrapped request, Method invoked has multiple input parameter");
+ }
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr1"));
}
}
- if(numberOfBodyPart > SIZE){
- if (log.isDebugEnabled()) {
- log.debug("As per WS-I compliance, Multi part WSDL with more than one body part not allowed for Doc/Lit NON Wrapped request, Method invoked has multiple input parameter");
- }
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("DocLitProxyHandlerErr1"));
+
+ //Lets handle case where there is one message part or one input parameter
+ Message message = null;
+
+ if (mps.size() !=0) {
+ message = createMessage(mps);
+ }
+ //no message part case or no input parameter
+ if (mps.size() == 0) {
+ message = createEmptyMessage();
}
+
+
+ return message;
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
}
-
- //Lets handle case where there is one message part or one input parameter
- Message message = null;
-
- try {
- if (mps.size() !=0) {
- message = createMessage(mps);
- }
- //no message part case or no input parameter
- if (mps.size() == 0) {
- message = createEmptyMessage();
- }
- } catch (JAXBException e) {
- throw new MarshalException("An error occured while creating the request message", e);
- } catch (MessageException e) {
- throw new MarshalException("An error occured while creating the request message", e);
- } catch (XMLStreamException e) {
- throw new MarshalException("An error occured while creating the request message", e);
- }
-
- return message;
}
+
+
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/DocLitWrappedMethodMarshallerImpl.java Thu Nov 9 18:09:13 2006
@@ -22,16 +22,16 @@
import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;
+import javax.xml.ws.WebServiceException;
+import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.OperationDescription;
import org.apache.axis2.jaxws.description.OperationDescriptionJava;
import org.apache.axis2.jaxws.description.ParameterDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
import org.apache.axis2.jaxws.marshaller.DocLitWrappedMethodMarshaller;
-import org.apache.axis2.jaxws.marshaller.MarshalException;
import org.apache.axis2.jaxws.marshaller.MethodParameter;
-import org.apache.axis2.jaxws.marshaller.UnmarshalException;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.Protocol;
@@ -58,14 +58,16 @@
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toJAXBObject(org.apache.axis2.jaxws.message.Message)
*/
@Override
- public Object demarshalResponse(Message message, Object[] inputArgs) throws UnmarshalException {
- if (log.isDebugEnabled()) {
- log.debug("Attempting to demarshal a document/literal wrapped response");
- }
-
- String className = operationDesc.getResponseWrapperClassName();
- Object businessObject = null;
+ public Object demarshalResponse(Message message, Object[] inputArgs) throws WebServiceException {
+
try {
+ if (log.isDebugEnabled()) {
+ log.debug("Attempting to demarshal a document/literal wrapped response");
+ }
+
+ String className = operationDesc.getResponseWrapperClassName();
+ Object businessObject = null;
+
//TODO Move this to Operation Description.
Class wrapperClazz = null;
if (className == null || (className != null && className.length() == 0)) {
@@ -89,174 +91,160 @@
Object resultObject = findProperty(resultName, businessObject);
return resultObject;
}
+ return businessObject;
} catch (Exception e) {
- throw new UnmarshalException(e);
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
}
-
- return businessObject;
+
}
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#toObjects(org.apache.axis2.jaxws.message.Message)
*/
@Override
- public Object[] demarshalRequest(Message message) throws UnmarshalException {
- String className = operationDesc.getRequestWrapperClassName();
+ public Object[] demarshalRequest(Message message) throws WebServiceException {
+ try {
+ String className = operationDesc.getRequestWrapperClassName();
- ArrayList<MethodParameter> mps;
- try {
- Class requestWrapperClazz = loadClass(className);
- Object jaxbObject = createBusinessObject(requestWrapperClazz, message);
-
- if (log.isDebugEnabled()) {
- log.debug("reading input method parameters");
- }
-
- mps = createParameterForSEIMethod(jaxbObject);
- } catch (Exception e) {
- throw new UnmarshalException(e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("done reading input method parameters");
- }
-
- Object[] contents = new Object[mps.size()];
- int i =0;
- for (MethodParameter mp:mps){
- contents[i++] =mp.getValue();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Object unwrapped");
- }
-
- return contents;
+ ArrayList<MethodParameter> mps;
+
+ Class requestWrapperClazz = loadClass(className);
+ Object jaxbObject = createBusinessObject(requestWrapperClazz, message);
+
+ if (log.isDebugEnabled()) {
+ log.debug("reading input method parameters");
+ }
+
+ mps = createParameterForSEIMethod(jaxbObject);
+
+
+ if (log.isDebugEnabled()) {
+ log.debug("done reading input method parameters");
+ }
+
+ Object[] contents = new Object[mps.size()];
+ int i =0;
+ for (MethodParameter mp:mps){
+ contents[i++] =mp.getValue();
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Object unwrapped");
+ }
+
+ return contents;
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
}
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromJAXBObject(java.lang.Object)
*/
@Override
- public Message marshalResponse(Object returnObject, Object[] holderObjects) throws MarshalException {
- Class wrapperClazz = null;
- String wrapperClazzName = operationDesc.getResponseWrapperClassName();
- // TODO: (JLB) REVIEW: I changed this from getRequestWrapper to getRewponseWrapper...
- String wrapperXMLElementName = operationDesc.getResponseWrapperLocalName();
- String wrapperTNS = operationDesc.getResponseWrapperTargetNamespace();
- String webResult = operationDesc.getResultName();
-
- try {
- //TODO Move this to Operation Description.
- if (wrapperClazzName == null || (wrapperClazzName != null && wrapperClazzName.length() == 0)) {
- if (log.isDebugEnabled()) {
- log.debug("No ResponseWrapper annotation found, using return type of method as response object");
- }
- wrapperClazz = getReturnType();
- wrapperClazzName = wrapperClazz.getName();
- }
- else {
- wrapperClazz = loadClass(wrapperClazzName);
- }
- } catch (ClassNotFoundException e) {
- throw new MarshalException("Unable to load wrapper class", e);
- }
-
- // Create all holders list
- ParameterDescription[] paramDescs = operationDesc.getParameterDescriptions();
- ArrayList<Object> objectList = new ArrayList<Object>();
- int index =0;
- for(ParameterDescription pd:paramDescs){
- Object value = holderObjects[index];
- if(pd.isHolderType()){
- objectList.add(value);
+ public Message marshalResponse(Object returnObject, Object[] holderObjects) throws WebServiceException {
+
+ try {
+ // Get the necessary information from the OperationDesc
+ Class wrapperClazz = null;
+ String wrapperClazzName = operationDesc.getResponseWrapperClassName();
+ String wrapperXMLElementName = operationDesc.getResponseWrapperLocalName();
+ String wrapperTNS = operationDesc.getResponseWrapperTargetNamespace();
+ String webResult = operationDesc.getResultName();
+
+ //TODO Move this to Operation Description.
+ if (wrapperClazzName == null || (wrapperClazzName != null && wrapperClazzName.length() == 0)) {
+ if (log.isDebugEnabled()) {
+ log.debug("No ResponseWrapper annotation found, using return type of method as response object");
+ }
+ wrapperClazz = getReturnType();
+ wrapperClazzName = wrapperClazz.getName();
+ }
+ else {
+ wrapperClazz = loadClass(wrapperClazzName);
}
- index++;
+
+
+ // Create all holders list
+ ParameterDescription[] paramDescs = operationDesc.getParameterDescriptions();
+ ArrayList<Object> objectList = new ArrayList<Object>();
+ int index =0;
+ for(ParameterDescription pd:paramDescs){
+ Object value = holderObjects[index];
+ if(pd.isHolderType()){
+ objectList.add(value);
+ }
+ index++;
+ }
+
+ ArrayList<MethodParameter> mps = null;
+
+ mps = new ArrayList<MethodParameter>();
+ if(objectList.size() == 0 && wrapperClazz.getName().equals("void")){
+ //No holders and return type void example --> public void someMethod() I will return empty ResponseWrapper in message body for this case.
+ //doNothing as there is nothing to wrap
+ }
+ if(objectList.size() == 0 && !wrapperClazz.getName().equals("void")){
+ //No holders but a return type example --> public ReturnType someMethod()
+ mps = createResponseWrapperParameter(returnObject);
+ }
+ else{
+ //Holders found and return type or no return type. example --> public ReturnType someMethod(Holder<String>) or public void someMethod(Holder<String>)
+ mps = createResponseWrapperParameter(returnObject, objectList.toArray());
+ }
+
+ JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
+ Object wrapper = wrapperTool.wrap(wrapperClazz, wrapperClazzName, mps);
+ Message message = createMessage(wrapper, wrapperClazz, wrapperXMLElementName, wrapperTNS);
+
+
+ return message;
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
}
- // No Holders found
- ArrayList<MethodParameter> mps = null;
- try {
- mps = new ArrayList<MethodParameter>();
- if(objectList.size() == 0 && wrapperClazz.getName().equals("void")){
- //No holders and return type void example --> public void someMethod() I will return empty ResponseWrapper in message body for this case.
- //doNothing as there is nothing to wrap
- }
- if(objectList.size() == 0 && !wrapperClazz.getName().equals("void")){
- //No holders but a return type example --> public ReturnType someMethod()
- mps = createResponseWrapperParameter(returnObject);
- }
- else{
- //Holders found and return type or no return type. example --> public ReturnType someMethod(Holder<String>) or public void someMethod(Holder<String>)
- mps = createResponseWrapperParameter(returnObject, objectList.toArray());
- }
- } catch (IllegalAccessException e) {
- throw new MarshalException("Unable to create method parameters list", e);
- } catch (InstantiationException e) {
- throw new MarshalException("Unable to create method parameters list", e);
- } catch (ClassNotFoundException e) {
- throw new MarshalException("Unable to create method parameters list", e);
- }
-
- Message message;
- try {
- JAXBWrapperTool wrapperTool = new JAXBWrapperToolImpl();
- Object wrapper = wrapperTool.wrap(wrapperClazz, wrapperClazzName, mps);
- message = createMessage(wrapper, wrapperClazz, wrapperXMLElementName, wrapperTNS);
- } catch (Exception e) {
- throw new MarshalException(e);
- }
-
- return message;
-
}
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.convertor.impl.MessageConvertorImpl#fromObjects(java.lang.Object[])
*/
@Override
- public Message marshalRequest(Object[] objects) throws MarshalException {
- String className = operationDesc.getRequestWrapperClassName();
- String localName = operationDesc.getRequestWrapperLocalName();
- String wrapperTNS = operationDesc.getRequestWrapperTargetNamespace();
-
- Class wrapperClazz = null;
- try {
- wrapperClazz = loadClass(className);
- }
- catch (ClassNotFoundException e) {
- throw new MarshalException("Unable to load wrapper class.", e);
- }
-
- //Get Name Value pair for input parameter Objects, skip AsyncHandler and identify Holders.
- Object jaxbObject = null;
- try {
- ArrayList<MethodParameter> methodParameters = createRequestWrapperParameters(objects);
- JAXBWrapperTool wrapTool = new JAXBWrapperToolImpl();
- if (log.isDebugEnabled()) {
- log.debug("JAXBWrapperTool attempting to wrap propertes in WrapperClass :" + wrapperClazz);
- }
+ public Message marshalRequest(Object[] objects) throws WebServiceException {
+ try {
+ String className = operationDesc.getRequestWrapperClassName();
+ String localName = operationDesc.getRequestWrapperLocalName();
+ String wrapperTNS = operationDesc.getRequestWrapperTargetNamespace();
+
+ Class wrapperClazz = null;
+
+ wrapperClazz = loadClass(className);
+
+ //Get Name Value pair for input parameter Objects, skip AsyncHandler and identify Holders.
+ Object jaxbObject = null;
+
+ ArrayList<MethodParameter> methodParameters = createRequestWrapperParameters(objects);
+ JAXBWrapperTool wrapTool = new JAXBWrapperToolImpl();
+ if (log.isDebugEnabled()) {
+ log.debug("JAXBWrapperTool attempting to wrap propertes in WrapperClass :" + wrapperClazz);
+ }
- jaxbObject = wrapTool.wrap(wrapperClazz, localName, methodParameters);
- if (log.isDebugEnabled()) {
- log.debug("JAXBWrapperTool wrapped following propertes :");
- }
- } catch (Exception e) {
- throw new MarshalException(e);
- }
-
- Message message = null;
- try {
- message = createMessage(jaxbObject, wrapperClazz, localName, wrapperTNS);
- } catch (JAXBException e) {
- throw new MarshalException(e);
- } catch (MessageException e) {
- throw new MarshalException(e);
- } catch (XMLStreamException e) {
- throw new MarshalException(e);
- }
-
- return message;
+ jaxbObject = wrapTool.wrap(wrapperClazz, localName, methodParameters);
+ if (log.isDebugEnabled()) {
+ log.debug("JAXBWrapperTool wrapped following propertes :");
+ }
+
+ Message message = createMessage(jaxbObject, wrapperClazz, localName, wrapperTNS);
+
+
+ return message;
+
+ } catch (Exception e) {
+ // Firewall. Only WebServiceExceptions are thrown
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
}
// FIXME: This is wrong. We first need to get the ClassLoader from the
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=473168&r1=473167&r2=473168
==============================================================================
--- 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 Thu Nov 9 18:09:13 2006
@@ -37,6 +37,7 @@
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Holder;
import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.jaxws.ExceptionFactory;
@@ -47,10 +48,8 @@
import org.apache.axis2.jaxws.description.ServiceDescription;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.marshaller.ClassUtils;
-import org.apache.axis2.jaxws.marshaller.MarshalException;
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
import org.apache.axis2.jaxws.marshaller.MethodParameter;
-import org.apache.axis2.jaxws.marshaller.UnmarshalException;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.MessageException;
@@ -84,60 +83,83 @@
this.protocol = protocol;
}
+
/* (non-Javadoc)
- * @see org.apache.axis2.jaxws.helper.XMLMessageConvertor#toJAXBObject(org.apache.axis2.jaxws.message.Message)
+ * @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#demarshalResponse(org.apache.axis2.jaxws.message.Message, java.lang.Object[])
*/
- public abstract Object demarshalResponse(Message message, Object[] inputArgs) throws UnmarshalException;
+ public abstract Object demarshalResponse(Message message, Object[] inputArgs) throws WebServiceException;
+
/* (non-Javadoc)
- * @see org.apache.axis2.jaxws.helper.XMLMessageConvertor#toObjects(org.apache.axis2.jaxws.message.Message)
+ * @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#demarshalRequest(org.apache.axis2.jaxws.message.Message)
*/
- public abstract Object[] demarshalRequest(Message message) throws UnmarshalException;
+ public abstract Object[] demarshalRequest(Message message) throws WebServiceException;
+
/* (non-Javadoc)
- * @see org.apache.axis2.jaxws.helper.XMLMessageConvertor#fromJAXBObject(java.lang.Object)
+ * @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#marshalResponse(java.lang.Object, java.lang.Object[])
*/
- public abstract Message marshalResponse(Object returnObject, Object[] holderObjects)throws MarshalException;
+ public abstract Message marshalResponse(Object returnObject, Object[] holderObjects)throws WebServiceException;
+
/* (non-Javadoc)
- * @see org.apache.axis2.jaxws.helper.XMLMessageConvertor#fromObjects(java.lang.Object[])
+ * @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#marshalRequest(java.lang.Object[])
*/
- public abstract Message marshalRequest(Object[] object)throws MarshalException;
+ public abstract Message marshalRequest(Object[] object)throws WebServiceException;
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#demarshalFaultResponse(org.apache.axis2.jaxws.message.Message)
*/
- public Object demarshalFaultResponse(Message message) throws UnmarshalException {
+ public Object demarshalFaultResponse(Message message) throws WebServiceException {
Exception exception = null;
try {
+ // Get the fault from the message and get the detail blocks (probably one)
XMLFault xmlfault = message.getXMLFault();
- //Class beanclass = (jaxbClassName == null || jaxbClassName.length() ==0 || className == null || className.length() == 0) ? null : loadClass(jaxbClassName);
Block[] blocks = xmlfault.getDetailBlocks();
+
if ((operationDesc.getFaultDescriptions().length == 0) || (blocks == null)) {
+ // This is a system exception if the method does not throw a checked exception or if
+ // there is nothing in the detail element.
exception = createGenericException(xmlfault.getReason()
.getText());
} else {
- for(FaultDescription fd: operationDesc.getFaultDescriptions()) {
- for (Block block: blocks) {
- Object obj = createFaultBusinessObject(loadClass(fd.getFaultBean()), block);
- if (obj.getClass().getName().equals(fd.getFaultBean())) {
- // create the exception we actually want to throw
- Class exceptionclass = loadClass(fd.getExceptionClassName());
- return createCustomException(xmlfault.getReason().getText(), exceptionclass, obj);
- }
- }
- }
- // if we get out of the for loop without returning anything, that means an endpoint
- // has thrown a custom exception that doesn't have an annotation -- that's illegal!
- exception = ExceptionFactory.makeWebServiceException("Endpoint has thrown a custom exception that has no annotation.");
+ // Create a JAXBContext object that can handle any of the
+ // checked exceptions defined on this operation
+ Class[] classes = new Class[operationDesc.getFaultDescriptions().length];
+ for(int i=0; i<operationDesc.getFaultDescriptions().length; i++) {
+ FaultDescription fd = operationDesc.getFaultDescriptions()[i];
+ classes[i] = loadClass(fd.getFaultBean());
+ }
+
+ // TODO what if there are multiple blocks in the detail ?
+ // We should create a generic fault with the appropriate detail
+ Block block = blocks[0];
+
+ // Now demarshal the block to get a business object (faultbean)
+ Object obj = createFaultBusinessObject(classes, block);
+
+ // Find the JAX-WS exception that can except this kind of fault bean
+ Class exceptionClass = null;
+ for(int i=0; i<operationDesc.getFaultDescriptions().length && exceptionClass == null; i++) {
+ FaultDescription fd = operationDesc.getFaultDescriptions()[i];
+ Class expectedFaultBean = loadClass(fd.getFaultBean());
+ if (expectedFaultBean.isAssignableFrom(obj.getClass())) {
+ exceptionClass = loadClass(fd.getExceptionClassName());
+ }
+ }
+
+ // Now create the JAX-WS Exception class
+ if (exceptionClass == null) {
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("MethodMarshallerErr1", obj.getClass().toString()));
+ }
+ return createCustomException(xmlfault.getReason().getText(), exceptionClass, obj);
}
} catch (Exception e) {
- // TODO if we have problems creating the exception object, we'll end up here,
- // where we should return at least a meaningfull exception to the user
- exception = ExceptionFactory.makeWebServiceException(e.toString());
+ // Catch all nested exceptions and throw WebServiceException
+ throw ExceptionFactory.makeWebServiceException(e);
}
return exception;
@@ -146,42 +168,41 @@
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.marshaller.MethodMarshaller#marshalFaultResponse(java.lang.Throwable)
*/
- public Message marshalFaultResponse(Throwable throwable) throws MarshalException {
- Throwable t = ClassUtils.getRootCause(throwable);
-
- FaultDescription fd = operationDesc.resolveFaultByExceptionName(t.getClass().getName());
+ public Message marshalFaultResponse(Throwable throwable) throws WebServiceException {
+ try {
+ Throwable t = ClassUtils.getRootCause(throwable);
- // if faultClazzName is still null, don't create a detail block. If it's non-null, we need a detail block.
- XMLFault xmlfault = null;
- ArrayList<Block> detailBlocks = new ArrayList<Block>();
-
- Message message = null;
- try {
- String text = null;
- if (fd != null) {
+ XMLFault xmlfault = null;
+
+ Message message = createEmptyMessage();
+
+ // Get the FaultDescriptor matching this Exception.
+ // If FaultDescriptor is found, this is a JAX-B Service Exception.
+ // 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);
Object faultBean = getFaultInfo.invoke(t, null);
- Class faultClazz = loadClass(fd.getFaultBean());
- JAXBBlockContext context = createJAXBBlockContext(faultClazz);
- detailBlocks.add(createJAXBBlock(faultBean, context));
+ JAXBBlockContext context = createJAXBBlockContext(faultBean.getClass());
+ Block[] detailBlocks = new Block[1];
+ detailBlocks[0] = createJAXBBlock(faultBean, context);
text = t.getMessage();
+ xmlfault = new XMLFault(null, new XMLFaultReason(text), detailBlocks);
} else {
- // TODO probably want to set text to the stacktrace
- text = t.toString();
+ // System Exception
+ xmlfault = new XMLFault(null, // Use the default XMLFaultCode
+ new XMLFaultReason(text)); // Assumes text is the language supported by the current Locale
}
- xmlfault = new XMLFault(null, // Use the default XMLFaultCode
- new XMLFaultReason(text), // Assumes text is the language supported by the current Locale
- detailBlocks.toArray(new Block[0]));
-
- message = createEmptyMessage();
+ // Add the fault to the message
message.setXMLFault(xmlfault);
+ return message;
} catch (Exception e) {
- throw new MarshalException(e);
+ // Catch all nested exceptions and throw WebServiceException
+ throw ExceptionFactory.makeWebServiceException(e);
}
-
- return message;
-
- //throw new UnsupportedOperationException();
}
/*
@@ -891,10 +912,17 @@
return blockContext;
}
- protected Object createFaultBusinessObject(Class jaxbClazz, Block block)
+ /**
+ * @param possibleClasses
+ * @param block
+ * @return
+ * @throws JAXBException
+ * @throws MessageException
+ * @throws XMLStreamException
+ */
+ protected Object createFaultBusinessObject(Class[] possibleClasses, Block block)
throws JAXBException, MessageException, XMLStreamException {
- JAXBBlockContext blockContext = createJAXBBlockContext(jaxbClazz);
-
+ JAXBBlockContext blockContext = new JAXBBlockContext(possibleClasses, false);
// Get a JAXBBlockFactory instance.
JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java Thu Nov 9 18:09:13 2006
@@ -22,13 +22,13 @@
/*
* A JAXBBlockContext controls access to the JAXB Context/Marshal/Unmarshal code.
* In addition the JAXBBlockContext contains additional contextural information needed
- * by the JAX-WS component (i.e. the type of the object)
+ * by the JAX-WS component (i.e. the possible type(s) of the object)
*
* This class is immutable after construction.
*/
public class JAXBBlockContext {
- private Class type = null;
+ private Class[] types = null;
private JAXBContext jaxbContext = null;
private boolean useJAXBElement = false;
@@ -58,7 +58,21 @@
* @param jaxbContext
*/
public JAXBBlockContext(Class type, boolean useJAXBElement, JAXBContext jaxbContext) {
- this.type = type;
+ this.types = new Class[] {type};
+ this.useJAXBElement = useJAXBElement;
+ this.jaxbContext = jaxbContext;
+ }
+
+ /**
+ * Constructor JAXBBlockContext
+ * @param types Class[] object that represents the actual type of the object.
+ * @param useJAXBElement boolean indicating whether the object should be rendered
+ * as a JAXBElement.
+ *
+ * This constructor is used when the demarshalling exceptions.
+ */
+ public JAXBBlockContext(Class[] types, boolean useJAXBElement) {
+ this.types = types;
this.useJAXBElement = useJAXBElement;
this.jaxbContext = jaxbContext;
}
@@ -66,8 +80,8 @@
/**
* @return Class representing type of the element
*/
- public Class getType() {
- return type;
+ public Class[] getTypes() {
+ return types;
}
/**
@@ -84,9 +98,9 @@
public JAXBContext getJAXBContext() throws JAXBException {
if (jaxbContext == null) {
if (!useJAXBElement) {
- jaxbContext = JAXBUtils.getJAXBContext(type);
+ jaxbContext = JAXBUtils.getJAXBContext(types);
} else {
- jaxbContext = JAXBUtils.getJAXBContext(type);
+ jaxbContext = JAXBUtils.getJAXBContext(types);
}
}
return jaxbContext;
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java Thu Nov 9 18:09:13 2006
@@ -16,6 +16,7 @@
*/
package org.apache.axis2.jaxws.message.databinding;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -84,9 +85,10 @@
* @return JAXBContext
* @throws JAXBException
*/
- public static JAXBContext getJAXBContext(Class cls) throws JAXBException {
+ public static JAXBContext getJAXBContext(Class[] classes) throws JAXBException {
// JAXBContexts for the same class can be reused and are supposed to be thread-safe
// TODO Can we cache by package name ?
+ Class cls = classes[0];
if (cls.isPrimitive()) {
return getGenericJAXBContext();
}
@@ -94,22 +96,22 @@
if (context == null) {
synchronized(map) {
try{
- Package pkg = cls.getPackage();
- if (log.isDebugEnabled()) {
- log.debug("Package for " + cls.getName() + " "+pkg.getName());
- }
- if (log.isDebugEnabled()) {
- log.debug("Attempting to read all classes from package " + pkg.getName());
- }
- List<Class> classList = ClassUtils.getAllClassesFromPackage(pkg.getName());
- Class[] classes = classList.toArray(new Class[0]);
- if (log.isDebugEnabled()) {
- log.debug("All classes from package " + pkg.getName() + "[read].");
- }
- if (log.isDebugEnabled()) {
- log.debug("Attempting to create JAXBContext for " + cls.getName());
- }
- context = JAXBContext.newInstance(classes);
+ // TODO
+ // For now we are generating a list of all of the classes in each
+ // of the referenced packages. We have plans to use a contextPath instead
+ List<Class> fullList = new ArrayList<Class>();
+ for (int i=0; i<classes.length; i++) {
+ Package pkg = classes[i].getPackage();
+ if (log.isDebugEnabled()) {
+ log.debug("Package for " + classes[i].getName() + " "+pkg.getName());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Attempting to read all classes from package " + pkg.getName());
+ }
+ fullList.addAll(ClassUtils.getAllClassesFromPackage(pkg.getName()));
+ }
+ Class[] classArray = fullList.toArray(new Class[0]);
+ context = JAXBContext.newInstance(classArray);
map.put(cls.getName(), context);
}catch(ClassNotFoundException e){
throw new JAXBException(e);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java Thu Nov 9 18:09:13 2006
@@ -107,9 +107,9 @@
// Normal Unmarshalling
jaxb = u.unmarshal(reader);
setQName(getQName(jaxb, ctx));
- }else{
+ } else {
// Unmarshal as a JAXBElement and then get the value
- JAXBElement jaxbElement = u.unmarshal(reader, ctx.getType());
+ JAXBElement jaxbElement = u.unmarshal(reader, ctx.getTypes()[0]);
jaxb = jaxbElement.getValue();
}
@@ -174,7 +174,14 @@
am.setMessage(msg);
m.setAttachmentMarshaller(am);
}
- m.marshal(busObject, writer);
+ if (busObject instanceof JAXBElement) {
+ m.marshal(busObject, writer);
+ } else {
+ JAXBElement b = new JAXBElement(this.getQName(), busObject.getClass(), busObject);
+ m.marshal(b, writer);
+ }
+
+
// Successfully marshalled the data
// TODO remove attachment marshaller ?
Added: webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/FaultsService.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/FaultsService.wsdl?view=auto&rev=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/FaultsService.wsdl (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/FaultsService.wsdl Thu Nov 9 18:09:13 2006
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<definitions name="FaultsService" targetNamespace="http://org/test/polymorphicfaults"
+ xmlns:tns="http://org/test/polymorphicfaults"
+ xmlns:ts="http://org/test/polymorphicfaults"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <xsd:schema targetNamespace="http://org/test/polymorphicfaults">
+
+ <xsd:element name="SimpleFault" type="xsd:int"/>
+ <xsd:element name="InvalidTickerFault" type="xsd:string"/>
+
+ <xsd:element name="BaseFault" type="ts:BaseFault"/>
+ <xsd:complexType name="BaseFault">
+ <xsd:sequence>
+ <xsd:element name="a" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="DerivedFault1" type="ts:DerivedFault1"/>
+ <xsd:complexType name="DerivedFault1">
+ <xsd:complexContent>
+ <xsd:extension base="ts:BaseFault">
+ <xsd:sequence>
+ <xsd:element name="b" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:element name="DerivedFault2" type="ts:DerivedFault2"/>
+ <xsd:complexType name="DerivedFault2">
+ <xsd:complexContent>
+ <xsd:extension base="ts:DerivedFault1">
+ <xsd:sequence>
+ <xsd:element name="c" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:element name="ComplexFault" type="ts:ComplexFault"/>
+ <xsd:complexType name="ComplexFault">
+ <xsd:complexContent>
+ <xsd:extension base="ts:DerivedFault2">
+ <xsd:sequence>
+ <xsd:element name="d" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:element name="getQuote">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getQuoteResult">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="result" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="throwFault">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="paramA" type="xsd:int"/>
+ <xsd:element name="paramB" type="xsd:string"/>
+ <xsd:element name="paramC" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="throwFaultReturn">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="returnFault">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="paramX" type="xsd:int"/>
+ <xsd:element name="paramY" type="xsd:string"/>
+ <xsd:element name="paramZ" type="xsd:float"/>
+ <xsd:element name="fault" type="ts:DerivedFault1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="returnFaultResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="fault" type="ts:DerivedFault1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+ </types>
+
+ <message name="SimpleFault">
+ <part name="faultMessage" element="ts:SimpleFault" />
+ </message>
+
+ <message name="InvalidTickerFault">
+ <part name="tickerFault" element="ts:InvalidTickerFault"/>
+ </message>
+
+ <message name="BaseFault">
+ <part name="baseFault" element="ts:BaseFault"/>
+ </message>
+
+ <message name="DerivedFault1">
+ <part name="theFault" element="ts:DerivedFault1" />
+ </message>
+
+ <message name="DerivedFault2">
+ <part name="theFault" element="ts:DerivedFault2" />
+ </message>
+
+ <message name="ComplexFault">
+ <part name="complexFault" element="ts:ComplexFault"/>
+ </message>
+
+ <message name="EqualFault">
+ <part name="theFault" element="ts:DerivedFault1" />
+ </message>
+
+ <message name="GetQuoteRequest">
+ <part name="tickerSymbol" element="ts:getQuote" />
+ </message>
+
+ <message name="GetQuoteResponse">
+ <part name="GetQuoteResult" element="ts:getQuoteResult" />
+ </message>
+
+ <message name="ThrowFaultRequest">
+ <part name="request" element="ts:throwFault" />
+ </message>
+
+ <message name="ThrowFaultResponse">
+ <part name="response" element="ts:throwFaultReturn"/>
+ </message>
+
+ <message name="ReturnFaultRequest">
+ <part name="req" element="ts:returnFault" />
+ </message>
+
+ <message name="ReturnFaultResponse">
+ <part name="return" element="ts:returnFaultResponse"/>
+ </message>
+
+ <portType name="FaultsServicePortType">
+ <operation name="getQuote">
+ <input message="tns:GetQuoteRequest"/>
+ <output message="tns:GetQuoteResponse"/>
+ <fault message="tns:InvalidTickerFault" name="InvalidTickerFault" />
+ <fault message="tns:SimpleFault" name="SimpleFault" />
+ <fault message="tns:DerivedFault1" name="Fault1"/>
+ <fault message="tns:DerivedFault2" name="Fault2"/>
+ <fault message="tns:BaseFault" name="Fault3"/>
+ </operation>
+
+ <operation name="throwFault">
+ <input message="tns:ThrowFaultRequest"/>
+ <output message="tns:ThrowFaultResponse"/>
+ <fault message="tns:BaseFault" name="baseFault" />
+ <fault message="tns:ComplexFault" name="complexFault" />
+ </operation>
+
+ <operation name="returnFault">
+ <input message="tns:ReturnFaultRequest"/>
+ <output message="tns:ReturnFaultResponse"/>
+ <fault message="tns:DerivedFault1" name="DerivedFault1" />
+ <fault message="tns:EqualFault" name="EqualFault" />
+ </operation>
+ </portType>
+
+ <binding name="FaultsServiceSoapBinding" type="tns:FaultsServicePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="getQuote">
+ <soap:operation soapAction="" style="document"/>
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ <fault name="InvalidTickerFault">
+ <soap:fault name="InvalidTickerFault" use="literal"/>
+ </fault>
+ <fault name="SimpleFault">
+ <soap:fault name="SimpleFault" use="literal"/>
+ </fault>
+ <fault name="Fault1">
+ <soap:fault name="Fault1" use="literal"/>
+ </fault>
+ <fault name="Fault2">
+ <soap:fault name="Fault2" use="literal"/>
+ </fault>
+ <fault name="Fault3">
+ <soap:fault name="Fault3" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="throwFault">
+ <soap:operation soapAction="" style="document"/>
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ <fault name="baseFault">
+ <soap:fault name="baseFault" use="literal"/>
+ </fault>
+ <fault name="complexFault">
+ <soap:fault name="complexFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="returnFault">
+ <soap:operation soapAction="" style="document"/>
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ <fault name="DerivedFault1">
+ <soap:fault name="DerivedFault1" use="literal"/>
+ </fault>
+ <fault name="EqualFault">
+ <soap:fault name="EqualFault" use="literal"/>
+ </fault>
+ </operation>
+ </binding>
+
+ <service name="FaultsService">
+ <port name="FaultsPort" binding="tns:FaultsServiceSoapBinding">
+ <soap:address location="http://localhost:9080/FaultsService/FaultsServiceSoapBindingImpl"/>
+ </port>
+ </service>
+</definitions>
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java Thu Nov 9 18:09:13 2006
@@ -88,8 +88,8 @@
throw ExceptionFactory.makeWebServiceException(wse);
} catch(WebServiceException e){
// Should only be a single WebServiceException with a Protocol Exception
- assertTrue(e.getMessage() == null);
assertTrue(e.getCause() == npe);
+ assertTrue(e.getCause().getMessage() == null);
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=473168&r1=473167&r2=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Thu Nov 9 18:09:13 2006
@@ -56,10 +56,12 @@
import org.apache.axis2.jaxws.proxy.ProxyTests;
import org.apache.axis2.jaxws.sample.AddNumbersTests;
import org.apache.axis2.jaxws.sample.AddressBookTests;
+import org.apache.axis2.jaxws.sample.FaultsServiceTests;
import org.apache.axis2.jaxws.sample.FaultyWebServiceTests;
import org.apache.axis2.jaxws.sample.MtomSampleTests;
import org.apache.axis2.jaxws.sample.NonWrapTests;
import org.apache.axis2.jaxws.sample.WrapTests;
+import org.apache.axis2.jaxws.sample.faultsservice.FaultsService;
import org.apache.axis2.jaxws.security.BasicAuthSecurityTests;
import org.apache.log4j.BasicConfigurator;
@@ -67,7 +69,7 @@
static {
// Enable debug
- // BasicConfigurator.configure();
+ //BasicConfigurator.configure();
}
/**
@@ -121,9 +123,13 @@
suite.addTestSuite(NonAnonymousComplexTypeTests.class);
suite.addTestSuite(AddNumbersTests.class);
suite.addTestSuite(FaultyWebServiceTests.class);
+
+ // TODO don't enable until working:
+ //suite.addTestSuite(FaultsServiceTests.class);
+
suite.addTestSuite(EndpointLifecycleTests.class);
suite.addTestSuite(ResourceInjectionTests.class);
-
+
// Start (and stop) the server only once for all the tests
TestSetup testSetup = new TestSetup(suite) {
public void setUp() {
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java?view=auto&rev=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java Thu Nov 9 18:09:13 2006
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.apache.axis2.jaxws.sample;
+
+import javax.xml.ws.BindingProvider;
+
+import org.apache.axis2.jaxws.sample.faultsservice.BaseFault_Exception;
+import org.test.polymorphicfaults.ComplexFault;
+import org.apache.axis2.jaxws.sample.faultsservice.ComplexFault_Exception;
+import org.test.polymorphicfaults.DerivedFault2;
+import org.apache.axis2.jaxws.sample.faultsservice.FaultsService;
+import org.apache.axis2.jaxws.sample.faultsservice.FaultsServicePortType;
+import junit.framework.TestCase;
+
+
+public class FaultsServiceTests extends TestCase {
+
+ String axisEndpoint = "http://localhost:8080/axis2/services/FaultsService";
+
+ public void testFaultsService1(){
+ //FaultyWebServiceFault_Exception exception = null;
+ Exception exception = null;
+ try{
+ System.out.println("----------------------------------");
+ System.out.println("test: " + getName());
+ FaultsService service = new FaultsService();
+ FaultsServicePortType proxy = service.getFaultsPort();
+ BindingProvider p = (BindingProvider)proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+
+ // the invoke will throw an exception, if the test is performed right
+ int total = proxy.throwFault(2, "a", 2);
+
+ }catch(BaseFault_Exception e){
+ exception = e;
+ } catch (ComplexFault_Exception e) {
+ fail("Should not get ComplexFault_Exception in this testcase");
+ }
+
+ System.out.println("----------------------------------");
+
+ assertNotNull(exception);
+ assertTrue(((BaseFault_Exception)exception).getFaultInfo() instanceof DerivedFault2);
+
+ }
+
+ public void testFaultsService2(){
+ //FaultyWebServiceFault_Exception exception = null;
+ Exception exception = null;
+ try{
+ System.out.println("----------------------------------");
+ System.out.println("test: " + getName());
+ FaultsService service = new FaultsService();
+ FaultsServicePortType proxy = service.getFaultsPort();
+ BindingProvider p = (BindingProvider)proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+
+ // the invoke will throw an exception, if the test is performed right
+ int total = proxy.throwFault(2, "Complex", 2); // "Complex" will cause service to throw ComplexFault_Exception
+
+ }catch(BaseFault_Exception e){
+ fail("Should not get BaseFault_Exception in this testcase");
+ } catch (ComplexFault_Exception e) {
+ exception = e;
+ }
+
+ System.out.println("----------------------------------");
+
+ assertNotNull(exception);
+ assertTrue(((BaseFault_Exception)exception).getFaultInfo() instanceof ComplexFault);
+
+ }
+
+}
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=473168&r1=473167&r2=473168
==============================================================================
--- 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 Thu Nov 9 18:09:13 2006
@@ -77,7 +77,7 @@
assertNotNull(exception);
assertTrue(exception.getCause() instanceof UnknownHostException);
- assertEquals(exception.getMessage(), host);
+ assertEquals(exception.getCause().getMessage(), host);
}
@@ -112,7 +112,7 @@
assertNotNull(exception);
assertTrue(exception.getCause() instanceof UnknownHostException);
- assertEquals(exception.getMessage(), host);
+ assertEquals(exception.getCause().getMessage(), host);
}
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/BaseFault_Exception.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/BaseFault_Exception.java?view=auto&rev=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/BaseFault_Exception.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/BaseFault_Exception.java Thu Nov 9 18:09:13 2006
@@ -0,0 +1,55 @@
+
+package org.apache.axis2.jaxws.sample.faultsservice;
+
+import org.test.polymorphicfaults.*;
+import javax.xml.ws.WebFault;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebFault(name = "BaseFault", targetNamespace = "http://org/test/polymorphicfaults")
+public class BaseFault_Exception
+ extends Exception
+{
+
+ /**
+ * Java type that goes as soapenv:Fault detail element.
+ *
+ */
+ private BaseFault faultInfo;
+
+ /**
+ *
+ * @param message
+ * @param faultInfo
+ */
+ public BaseFault_Exception(String message, BaseFault faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ *
+ * @param cause
+ * @param message
+ * @param faultInfo
+ */
+ public BaseFault_Exception(String message, BaseFault faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ *
+ * @return
+ * returns fault bean: org.test.polymorphicfaults.BaseFault
+ */
+ public BaseFault getFaultInfo() {
+ return faultInfo;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/ComplexFault_Exception.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/ComplexFault_Exception.java?view=auto&rev=473168
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/ComplexFault_Exception.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/ComplexFault_Exception.java Thu Nov 9 18:09:13 2006
@@ -0,0 +1,55 @@
+
+package org.apache.axis2.jaxws.sample.faultsservice;
+
+import org.test.polymorphicfaults.*;
+import javax.xml.ws.WebFault;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebFault(name = "ComplexFault", targetNamespace = "http://org/test/polymorphicfaults")
+public class ComplexFault_Exception
+ extends Exception
+{
+
+ /**
+ * Java type that goes as soapenv:Fault detail element.
+ *
+ */
+ private ComplexFault faultInfo;
+
+ /**
+ *
+ * @param message
+ * @param faultInfo
+ */
+ public ComplexFault_Exception(String message, ComplexFault faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ *
+ * @param cause
+ * @param message
+ * @param faultInfo
+ */
+ public ComplexFault_Exception(String message, ComplexFault faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ *
+ * @return
+ * returns fault bean: org.test.polymorphicfaults.ComplexFault
+ */
+ public ComplexFault getFaultInfo() {
+ return faultInfo;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org