Hi,
I develop a contract first web service. I want to be able to send two
different kinds of SOAP faults for one of my operations. But on the client
side, when an exception is thrown, I get a SOAPFaultException and not my own
exceptions defined in my WSDL.

When I used only one fault for my service, it worked well, but not with two
faults.

Here is how it is defined in the WSDL for now:

<xsd:element name="LoginFault">
          <xsd:complexType>
              <xsd:sequence>
                  <xsd:element name="message" type="xsd:string"
maxOccurs="1" minOccurs="1"></xsd:element>
                  <xsd:element name="code" type="xsd:int" maxOccurs="1"
minOccurs="0"></xsd:element>
              </xsd:sequence>
          </xsd:complexType>
      </xsd:element>

      <xsd:element name="MaxUsersFault">
          <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="message" type="xsd:string" maxOccurs="1"
minOccurs="1"></xsd:element>
            </xsd:sequence>
          </xsd:complexType>
      </xsd:element>

[...]

<wsdl:message name="login_faultMsg">
      <wsdl:part name="parameters" element="tns:LoginFault"></wsdl:part>
</wsdl:message>
  <wsdl:message name="maxUsers_faultMsg">
      <wsdl:part name="parameters" element="tns:MaxUsersFault"></wsdl:part>
  </wsdl:message>

[...]

<wsdl:operation name="login">
      <wsdl:input message="tns:loginRequest"/>
      <wsdl:output message="tns:loginResponse"/>
      <wsdl:fault name="fault" message="tns:login_faultMsg"></wsdl:fault>
      <wsdl:fault name="maxUsersFault"
message="tns:maxUsers_faultMsg"></wsdl:fault>
</wsdl:operation>

I generate the code for both client and server using wsdl2java.

On server side, I do:
LoginFault fault = new LoginFault();
fault.setMessage("some message");
throw new LoginFaultMsg("Could not log in", fault);

But On the client side, I can only catch a SOAPFaultException, not a
LoginFaultMsg :o(

Here is an example of the SOAP message sent over the wire:
<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";<http://schemas.xmlsoap.org/soap/envelope/>><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Could
not log in</faultstring><detail><ns2:LoginFault xmlns:ns2=
"http://www.net-vitesse.com/login/loginService/";<http://www.net-vitesse.com/login/loginService/>><message>Some
message</message></ns2:LoginFault></detail></soap:Fault></soap:Body></soap:Envelope>

Do you have any idea what could go wrong?
How does CXF knows what is the type of exception that is thrown ? It seems
it cannot recognize it.

Thanks.


--
Antoine Roux,
NetVitesse S.A.R.L
[email protected]
Phone: +33 (0)1 61 37 04 24
Mobile: +33 (0)6 20 69 07 96

Reply via email to