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 "Heitzeg, Bill" <bi...@sabre.com> on 2004/01/15 17:53:47 UTC
Mapping exceptions to faults using Doc Literal
I'm am trying to map a java exception to a SOAP fault using a Doc Literal structure. I'm generating the WSDL from my Java Code. I'm having a very easy time with complex data types, but I can't figure out what I need to do to map an exception to a fault. I think I've listed all the relevant information below, but let me know if there is something missing.
thanks,
Bill Heitzeg
My WebService Class looks like:
package com.sabre.cruise.webservices.prototype;
/**
The <code>ClassName</code> class is used
@author <a href="mailto: bill.heitzeg.ctr@sabre.com">Bill Heitzeg</a>
@version 1.0
*/
public class BillWebService
{
public ReallyComplexDataType HelloWorld( ComplexDataType myComplexDataType) throws BillWebServiceFault
{
String inputString = myComplexDataType.getString();
if ( inputString.compareTo("XXXX")==0)
throw new BillWebServiceFault("A Sample Exception");
ComplexDataType nestedDataType = new ComplexDataType();
nestedDataType.setString("Nested Data Type String");
ReallyComplexDataType reallyComplexDataType = new ReallyComplexDataType();
reallyComplexDataType.setReturnMessage("Hello " + myComplexDataType.getString() + " welcome to Complex Data Types!");
reallyComplexDataType.setNestedDataType( nestedDataType );
return reallyComplexDataType;
}
}
My Exception class looks like:
package com.sabre.cruise.webservices.prototype;
/**
* @author sg910604
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class BillWebServiceFault extends Exception
{
/**
*
*/
public BillWebServiceFault()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @param message
*/
public BillWebServiceFault(String message)
{
super(message);
// TODO Auto-generated constructor stub
}
/**
* @param message
* @param cause
*/
public BillWebServiceFault(String message, Throwable cause)
{
super(message, cause);
// TODO Auto-generated constructor stub
}
/**
* @param cause
*/
public BillWebServiceFault(Throwable cause)
{
super(cause);
// TODO Auto-generated constructor stub
}
Here's my service description in the .wsdd
<service name="BillWebService" provider="java:RPC" style="wrapped" use="literal">
<responseFlow>
<handler type="SOAPMessageLogging"/>
</responseFlow>
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value="com.sabre.cruise.webservices.prototype.BillWebService"/>
<wsdlFile>/BillWebService.wsdl</wsdlFile>
<beanMapping languageSpecificType="java:com.sabre.cruise.webservices.prototype.ComplexDataType"/>
<beanMapping languageSpecificType="java:com.sabre.cruise.webservices.prototype.ReallyComplexDataType"/>
</service>
Finally, here's the javatowsdl Ant task:
<!-- 3) Generate the WSDL (This can be done automatically by Axis, but we've chosen to do it ahead of time) -->
<target name="generateWSDL" depends="createJar">
<axis-java2wsdl classname="com.sabre.cruise.webservices.prototype.BillWebService"
methods="HelloWorld"
output="wsdl/BillWebService.wsdl"
location="http://localhost:8080/Calculate_axis/services/BillWebService"
namespace="http://localhost:8080/Calculate_axis/services/BillWebService"
namespaceImpl="http://localhost:8080/Calculate_axis/services/BillWebService"
style="WRAPPED"
>
<classpath path="lib/Calculate.jar" />
</axis-java2wsdl>
</target>
Bill Heitzeg
1-734-995-9131
RE: Mapping exceptions to faults using Doc Literal
Posted by Ias <ia...@tmax.co.kr>.
I once heard from Jongjin that the current Axis missed this function, in
other words, mapping a service specific Java exception to wsdl:fault based
on JAX-RPC spec 1.1 section 5.5.5 "Methods" Exceptions.
What do you think of that?
Ias
=========================================================
Lee, Changshin (Korean name)
Ias (International name)
Company Web Site: http://www.tmax.co.kr
Personal Web Site: http://www.iasandcb.pe.kr
---------------------------------------------------------
JSR 201, JSR 204 and JSR 222 EG member
Apache Axis (JAX-RPC and SAAJ) and JaxMe (JAXB) committer
R&D Institute
Tmax Soft, Inc.
=========================================================
> -----Original Message-----
> From: Heitzeg, Bill [mailto:bill.heitzeg.ctr@sabre.com]
> Sent: Friday, January 16, 2004 1:54 AM
> To: axis-dev@ws.apache.org
> Subject: Mapping exceptions to faults using Doc Literal
>
> I'm am trying to map a java exception to a SOAP fault using a
> Doc Literal structure. I'm generating the WSDL from my Java
> Code. I'm having a very easy time with complex data types,
> but I can't figure out what I need to do to map an exception
> to a fault. I think I've listed all the relevant information
> below, but let me know if there is something missing.
>
> thanks,
>
> Bill Heitzeg
>
> My WebService Class looks like:
>
> package com.sabre.cruise.webservices.prototype;
>
> /**
> The <code>ClassName</code> class is used
>
> @author <a href="mailto: bill.heitzeg.ctr@sabre.com">Bill
> Heitzeg</a> @version 1.0 */ public class BillWebService {
> public ReallyComplexDataType HelloWorld(
> ComplexDataType myComplexDataType) throws BillWebServiceFault
> {
> String inputString = myComplexDataType.getString();
> if ( inputString.compareTo("XXXX")==0)
> throw new BillWebServiceFault("A Sample
> Exception");
>
> ComplexDataType nestedDataType = new ComplexDataType();
> nestedDataType.setString("Nested Data Type String");
> ReallyComplexDataType reallyComplexDataType =
> new ReallyComplexDataType();
> reallyComplexDataType.setReturnMessage("Hello "
> + myComplexDataType.getString() + " welcome to Complex Data Types!");
> reallyComplexDataType.setNestedDataType(
> nestedDataType );
> return reallyComplexDataType;
> }
> }
>
>
> My Exception class looks like:
>
> package com.sabre.cruise.webservices.prototype;
>
>
> /**
> * @author sg910604
> *
> * To change the template for this generated type comment go to
> * Window>Preferences>Java>Code Generation>Code
> and Comments */ public class BillWebServiceFault extends Exception {
> /**
> *
> */
> public BillWebServiceFault()
> {
> super();
> // TODO Auto-generated constructor stub
> }
>
> /**
> * @param message
> */
> public BillWebServiceFault(String message)
> {
> super(message);
> // TODO Auto-generated constructor stub
> }
>
> /**
> * @param message
> * @param cause
> */
> public BillWebServiceFault(String message, Throwable cause)
> {
> super(message, cause);
> // TODO Auto-generated constructor stub
> }
>
> /**
> * @param cause
> */
> public BillWebServiceFault(Throwable cause)
> {
> super(cause);
> // TODO Auto-generated constructor stub
> }
>
>
> Here's my service description in the .wsdd
>
> <service name="BillWebService" provider="java:RPC"
> style="wrapped" use="literal">
> <responseFlow>
> <handler type="SOAPMessageLogging"/>
> </responseFlow>
> <parameter name="allowedMethods" value="*"/>
> <parameter name="className"
> value="com.sabre.cruise.webservices.prototype.BillWebService"/>
> <wsdlFile>/BillWebService.wsdl</wsdlFile>
> <beanMapping
> languageSpecificType="java:com.sabre.cruise.webservices.protot
> ype.ComplexDataType"/>
> <beanMapping
> languageSpecificType="java:com.sabre.cruise.webservices.protot
> ype.ReallyComplexDataType"/>
> </service>
>
> Finally, here's the javatowsdl Ant task:
> <!-- 3) Generate the WSDL (This can be done
> automatically by Axis, but we've chosen to do it ahead of time) -->
> <target name="generateWSDL" depends="createJar">
> <axis-java2wsdl
> classname="com.sabre.cruise.webservices.prototype.BillWebService"
> methods="HelloWorld"
> output="wsdl/BillWebService.wsdl"
>
> location="http://localhost:8080/Calculate_axis/services/BillWe
> bService"
>
> namespace="http://localhost:8080/Calculate_axis/services/BillW
> ebService"
>
> namespaceImpl="http://localhost:8080/Calculate_axis/services/B
> illWebService"
> style="WRAPPED"
> >
> <classpath path="lib/Calculate.jar" />
> </axis-java2wsdl>
> </target>
>
>
>
>
>
> Bill Heitzeg
> 1-734-995-9131
>
>