axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arne M. Degenring" <a...@degenring.de>
Subject Set your own SOAP fault code - Workaround for [Bug 10788]
Date Fri, 19 Jul 2002 13:21:29 GMT
I think I've found a workaround for Bug 10788, and a way to set my own
SOAP Fault Code:

The idea is to create a class "CustomAxisFault" which is a subclass of
"AxisFault". If you want to throw an Exception that should be mapped to
your own SOAP fault code, do it like this:

	public void test() throws CustomAxisFault {
		throw new CustomAxisFault(
			new QName("http://your.ns","YourOwnFaultCode"),
			"Your own fault string",
			null,
			new Element[0]);
		}
	}

The SOAP messages generated by Axis will be perfectly ok, but not the
auto-generated WSDL definition: The WSDL contains all the fields that
are inherited by AxisFault. As a work-around I implemented my own
"EmptyBeanSerializer". It does nothing on serialize(), and writes an
empty "complexType" Element on writeSchema().

You will find the classes, a sample web service "TestCustomAxisFault"
and the WSDD attached. Put all the files into a "<...>\de\degenring"
subdirectory, as the classes belong to the de.degenring package.

I tested it successfully with Axis beta-3 on the server side, and both
Axis and .NET as client platforms.

Let me know what you think.

- Arne



-----Original Message-----
From: bugzilla@apache.org [mailto:bugzilla@apache.org] 
Sent: Sunday, July 14, 2002 6:57 PM
To: arne@degenring.de
Subject: DO NOT REPLY [Bug 10788] New: - Web Service throwing AxisFault
leads to corrupt WSDL


DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10788>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10788

Web Service throwing AxisFault leads to corrupt WSDL

           Summary: Web Service throwing AxisFault leads to corrupt WSDL
           Product: Axis
           Version: current (nightly)
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: WSDL processing
        AssignedTo: axis-dev@xml.apache.org
        ReportedBy: arne@degenring.de


I already reported this some days ago on axis-user, but got no response.
I now 
have attached the files so that you can reproduce the bug quicker.

Have a look at the attached TestSOAPFault Web Service. The testMethod()
throws 
an AxisFault with my own SOAP fault code.

The SOAP response that is returned by the service and contains the SOAP
Fault 
seems to be perfectly ok. I also accessed the web service from the .NET 
platform. I could generate a proxy class using wsdl.exe. From a simple
.NET 
test client I could perfectly access the SOAP fault code. 

BUT: The WSDL definition generated by Axis must be corrupt. WSDL2Java is
not 
able to generate a proxy out of the WSDL definition. Error 
message: "java.io.IOException: Type {http://axis.apache.org}AxisFault is

referenced but not defined."

BTW: I'm using beta-3 (this option is still missing in Bugzilla).


-----

package de.degenring;

import javax.xml.namespace.QName;
import org.apache.axis.AxisFault;
import org.w3c.dom.Element;

public class TestSOAPFault{

    public void testMethod() throws AxisFault {
    	throw new AxisFault(
      	new QName("http://degenring.de","MyOwnFaultCode"), "This is a
SOAP 
Fault with custom faultcode", null, new Element[0]);
    }
}

-----

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
 <service name="TestSOAPFault" provider="java:RPC" 
xmlns:myNS="http://degenring.de">
  <parameter name="className" value="de.degenring.TestSOAPFault"/>
  <parameter name="allowedMethods" value="testMethod"/>  </service>
</deployment>

Mime
View raw message