Hi,

I'm having problems returning SOAP faults from Axis2/Java 1.1.1 when
using methods that use the InOnly receiver (i.e. ones that don't
return any data).

Instead of retuning a "HTTP/1.1 500 Internal Server Error" response,
it returns "HTTP/1.1 202 Accepted".

I believe that the 500 response is correct:

"In case of a SOAP error while processing the request, the SOAP HTTP
server MUST issue an HTTP 500 "Internal Server Error" response and
include a SOAP message in the response containing a SOAP Fault element
(see section 4.4) indicating the SOAP processing error."
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383529

To demonstrate I've created some WSDL that has two methods - one that
doesn't return any data ("in"), and one that does ("inout"):

--- Begin test.wsdl -----------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
       xmlns:tns="http://www.example.org/test/";
       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"; name="test"
       targetNamespace="http://www.example.org/test/";>

       <wsdl:types>
               <xsd:schema targetNamespace="http://www.example.org/test/";>
                       <xsd:element name="in" type="xsd:string" />
                       <xsd:element name="inout" type="xsd:string" />
                       <xsd:element name="inoutResponse" type="xsd:string" />
               </xsd:schema>
       </wsdl:types>

       <wsdl:message name="inRequest">
               <wsdl:part name="parameters" element="tns:in" />
       </wsdl:message>
       <wsdl:message name="inoutRequest">
               <wsdl:part name="inoutRequest" element="tns:inout" />
       </wsdl:message>
       <wsdl:message name="inoutResponse">
               <wsdl:part name="parameters" element="tns:inoutResponse" />
       </wsdl:message>

       <wsdl:portType name="test">
               <wsdl:operation name="in">
                       <wsdl:input message="tns:inRequest"></wsdl:input>
               </wsdl:operation>
               <wsdl:operation name="inout">
                       <wsdl:input message="tns:inoutRequest"></wsdl:input>
                       <wsdl:output message="tns:inoutResponse"></wsdl:output>
               </wsdl:operation>
       </wsdl:portType>

       <wsdl:binding name="testSOAP" type="tns:test">
               <soap:binding style="document"
                       transport="http://schemas.xmlsoap.org/soap/http"; />
               <wsdl:operation name="in">
                       <soap:operation
soapAction="http://www.example.org/test/in"; />
                       <wsdl:input>
                               <soap:body use="literal" />
                       </wsdl:input>
               </wsdl:operation>
               <wsdl:operation name="inout">
                       <soap:operation

soapAction="http://www.example.org/test/inout"; />
                       <wsdl:input>
                               <soap:body use="literal" />
                       </wsdl:input>
                       <wsdl:output>
                               <soap:body use="literal" />
                       </wsdl:output>
               </wsdl:operation>
       </wsdl:binding>

       <wsdl:service name="test">
               <wsdl:port binding="tns:testSOAP" name="testSOAP">
                       <soap:address location="http://www.example.org/"; />
               </wsdl:port>
       </wsdl:service>

</wsdl:definitions>

--- End test.wsdl -------------------------------------------------------

I then create the Java classes from the WSDL:

wsdl2java -uri test.wsdl -ss -sd

I then populate the skeleton class with code that throws AxisFaults:

--- Begin src/org/example/www/test/TestSkeleton.java --------------------

package org.example.www.test;

import org.apache.axis2.AxisFault;

public class TestSkeleton{

       public InoutResponse inout(Inout param0) throws AxisFault {
               throw new AxisFault("Inout AxisFault");
       }

       public  void in(In param2) throws AxisFault {
               throw new AxisFault("In AxisFault");
       }
}

--- End src/org/example/www/test/TestSkeleton.java ----------------------

I then build the aar file using ant and the wsdl2java-created
build.xml and deploy it to my Tomcat 5.0.28 server.

I then use Eclipse's Web Services Explorer to invoke the web service,
proxying the requests through Apache TCPMon so that I can view the
headers.

These are the responses I see:

--- Begin response to "inout" SOAP message ------------------------------

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml;charset=utf-8
Date: Fri, 09 Mar 2007 14:23:47 GMT
Server: Apache-Coyote/1.1
Connection: close

<?xml version='1.0' encoding='utf-8'?>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
     <soapenv:Header />
     <soapenv:Body>
        <soapenv:Fault>
           <faultcode>soapenv:Client</faultcode>
           <faultstring>Inout AxisFault</faultstring>
           <detail />
        </soapenv:Fault>
     </soapenv:Body>
  </soapenv:Envelope>

--- End response to "inout" SOAP message --------------------------------

--- Begin response to "in" SOAP message ---------------------------------

HTTP/1.1 202 Accepted
Content-Type: text/xml;charset=utf-8
Date: Fri, 09 Mar 2007 14:20:11 GMT
Server: Apache-Coyote/1.1
Connection: close

<?xml version='1.0' encoding='utf-8'?>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
     <soapenv:Header />
     <soapenv:Body>
        <soapenv:Fault>
           <faultcode>soapenv:Client</faultcode>
           <faultstring>In AxisFault</faultstring>
           <detail />
        </soapenv:Fault>
     </soapenv:Body>
  </soapenv:Envelope>

--- End response to "in" SOAP message -----------------------------------

Am I doing something wrong, or is this a bug?

A separate issue, I think, but I also see an exception in my Tomcat
log when a 500 response is returned:

[EMAIL PROTECTED]: Exception
Processing ErrorPage[errorCode=500,
location=/axis2-web/Error/error500.jsp]
java.lang.IllegalStateException
        at org.apache.coyote.Response.reset(Response.java:296)

Is this Axis erroneously trying to return "error500.jsp" after the
SOAP response has already been sent (i.e. too late)?

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to