Two answers:

1) I have used both 2.1 2007/09/06 SNAPSHOT and 2.0.1 released.

2) Here's the fault class:
> package com.firedrum.webservice.service; import javax.xml.ws.WebFault; import
> com.firedrum.webservice.types.MemberIdInfoType; /** * This class was generated
> by the CXF 2.0-incubator-SNAPSHOT * Wed Aug 15 18:53:53 MST 2007 * Generated
> source version: 2.0-incubator-SNAPSHOT */ @WebFault(name = "MemberIdInfo",
> targetNamespace = "http://service.webservice.firedrum.com/";) public class
> MemberExistsFault extends Exception {    private MemberIdInfoType
> memberIdInfoType;    public MemberExistsFault (String message) {
> super(message);    }    public MemberExistsFault (String message,
> MemberIdInfoType memberIdInfoType) {        super(message);
> this.memberIdInfoType = memberIdInfoType;    }    public MemberExistsFault
> (String message, MemberIdInfoType memberIdInfoType, Throwable cause) {
> super(message, cause);        this.memberIdInfoType = memberIdInfoType;    }
> public MemberIdInfoType getFaultInfo() {        return this.memberIdInfoType;
> } } 
> 
Thanks - Richard





> From: Daniel Kulp <[EMAIL PROTECTED]>
> Reply-To: <[email protected]>
> Date: Fri, 14 Sep 2007 13:38:05 -0400
> To: <[email protected]>
> Cc: Richard Mixon <[EMAIL PROTECTED]>
> Subject: Re: Not able to catch desired Fault type
> 
> 
> Two questions:
> 
> 1) What version of CXF are you using?   I did fix a few issues around
> faults for 2.0.1 and a few more for 2.0.2 (which is being voted on).
> 
> 2) What does the exception class look like?   Is it the one generated
> from wsdl2java or a hand coded exception class?
> 
> Dan
> 
> 
> On Wednesday 12 September 2007, Richard Mixon wrote:
>> 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>
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> [EMAIL PROTECTED]
> http://www.dankulp.com/blog
> 

Reply via email to