Fault is being returned as general SOAPFaultException instead of specific fault
-------------------------------------------------------------------------------

                 Key: CXF-1028
                 URL: https://issues.apache.org/jira/browse/CXF-1028
             Project: CXF
          Issue Type: Bug
    Affects Versions: 2.0.1, 2.1
         Environment: Mac OS X 10.4.10
            Reporter: Richard Mixon
         Attachments: acmeSTP.jar

I posted on the cxf-user list - my WSDL and the SOAP log. On the surface things 
looked like they should be working. both Daniel Kulp and Jervis Liu responded.

Jervis Liu suggested I zip up my code and post it as a JIRA incident so it 
could be better looked at.

I have zipped up a simplified version of my code that still shows the wrong 
exception being caught. I did ommit the jar files (commons-logging, cxf, etc) 
to reduce space - so the zip is very small ~ 115KB.

I have dummied things out - no database access or anything.

My original post is titled "Not able to catch desired Fault type" and was 
posted at 8:15MST on September 12.

Below is the text of the original post. I will attach my code (as I mentioned 
above).

Thank you - Richard Mixon





------ Forwarded Message
From: Richard Mixon <[EMAIL PROTECTED]>
Date: Wed, 12 Sep 2007 20:15:46 -0700
To: <[EMAIL PROTECTED]>
Conversation: Not able to catch desired Fault type
Subject: Not able to catch desired Fault type

I would appreciate some help trying to understand how to catch faults that are 
defined in my WSDL in a Java client.

My web service appears to be correctly throwing a specific Fault - 
MemberExistsFault - when trying to add a record and the member already exists. 

However when I catch it on the client, I am not able to catch a 
MemberExistsFault. Instead the exception can be caught as a
    javax.xml.ws.soap.SOAPFaultException
which in turn has a cause of
    org.apache.cxf.binding.soap.SoapFault.


Here is what the log shows on the server:
INFO: Outbound Message 
--------------------------------------
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope";>
  <soap:Body>
    <soap:Fault>
      <soap:Code>
        <soap:Value>soap:Receiver</soap:Value>
      </soap:Code>
      <soap:Reason>
        <soap:Text xml:lang ="en">
          Member cannot be added, it is already in the database
        </soap:Text>
      </soap:Reason>
      <soap:Detail>
        <ns2:memberIdInfoType xmlns:ns2="http://service.webservice.acme.com/";>
          <emailAddress xmlns="">[EMAIL PROTECTED]</emailAddress>
          <lastName xmlns="">myLastName</lastName>
          <firstName xmlns="">myFirstName3</firstName>
        </ns2:memberIdInfoType>
      </soap:Detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>
--------------------------------------

Below are the key parts of the WSDL (I can send the whole thing if necessary).

Thanks in advance - Richard

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="MemberServiceService"
  targetNamespace="http://service.webservice.acme.com/";
  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/";
  xmlns:ns1="http://service.webservice.acme.com/";
  xmlns:tns="http://types.webservice.firedrum.com/";
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>
  <wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
      xmlns:tns="http://types.webservice.acme.com/";
      attributeFormDefault="unqualified" elementFormDefault="unqualified"
      targetNamespace="http://types.webservice.acme.com/";>
 ...
      <xs:element name="MemberIdInfo"
        type="tns:MemberIdInfoType">
      </xs:element>
      <xs:complexType name="MemberIdInfoType">
        <xs:sequence>
          <xs:element name="emailAddress" type="xs:string"></xs:element>
          <xs:element name="lastName" type="xs:string"></xs:element>
          <xs:element name="firstName" type="xs:string"></xs:element>
        </xs:sequence>
      </xs:complexType>
        </xs:schema>
  </wsdl:types>

 ...
  <wsdl:message name="MemberExistsFault">
   <wsdl:part name="MemberIdInfo" element="tns:MemberIdInfo">
    </wsdl:part>
  </wsdl:message>

 ...
 <wsdl:portType name="MemberService">

   <wsdl:operation name="addMember">
     <wsdl:input name="addMember" message="ns1:addMember">
     </wsdl:input>
     <wsdl:output name="addMemberResponse"
       message="ns1:addMemberResponse">
     </wsdl:output>
     <wsdl:fault name="InvalidClientFault"
       message="ns1:InvalidClientFault">
     </wsdl:fault>
     <wsdl:fault name="MemberExistsFault"
       message="ns1:MemberExistsFault">
     </wsdl:fault>
     <wsdl:fault name="InvalidEmailAddressFault"
       message="ns1:InvalidEmailAddressFault">
     </wsdl:fault>
     <wsdl:fault name="CategoryNotFoundFault"
       message="ns1:CategoryNotFoundFault">
     </wsdl:fault>
     <wsdl:fault name="CustomFieldTypeNotFoundFault"
       message="ns1:CustomFieldTypeNotFoundFault">
     </wsdl:fault>
         <wsdl:fault name="AddMemberUnknownFault" 
message="ns1:AddMemberUnknownFault"></wsdl:fault>
     </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="MemberServiceServiceSoapBinding"
        type="ns1:MemberService">
  <soap12:binding style="document"
            transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"; />        
    
    
    <wsdl:operation name="addMember">
      <soap12:operation soapAction="" style="document" />
      <wsdl:input name="addMember">
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output name="addMemberResponse">
        <soap12:body use="literal" />
      </wsdl:output>
      <wsdl:fault name="InvalidClientFault"/>
      <wsdl:fault name="MemberExistsFault"/>
      <wsdl:fault name="InvalidEmailAddressFault"/>
      <wsdl:fault name="CategoryNotFoundFault"/>
      <wsdl:fault name="CustomFieldTypeNotFoundFault"/>
            <wsdl:fault name="AddMemberUnknownFault"/>
    </wsdl:operation>
    <wsdl:service name="MemberServiceService">
      <wsdl:port name="MemberServicePort"
            binding="ns1:MemberServiceServiceSoapBinding">
      <soap12:address location="http://localhost:8080/services/MemberService"; />
     </wsdl:port>
   </wsdl:service>
</wsdl:definitions>


------ End of Forwarded Message


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to