axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Heitzeg, Bill" <bill.heitzeg....@sabre.com>
Subject Mapping exceptions to faults using Doc Literal
Date Thu, 15 Jan 2004 16:53:47 GMT
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&gt;Preferences&gt;Java&gt;Code Generation&gt;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



Mime
View raw message