Hi,
 
I want to know if there is a way by which the exceptions that are being thrown in the web service will go back to the client in proper SOAPFault elements. I tried to change the WSDL to include the fault, shown below:
 
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://docws.syndeopeas.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:intf="http://docws.syndeopeas.com" xmlns:impl="http://docws.syndeopeas.com">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
  <wsdl:types>
    <schema elementFormDefault="qualified" targetNamespace="http://docws.syndeopeas.com" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://docws.syndeopeas.com" xmlns:intf="http://docws.syndeopeas.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <element name="add">
    <complexType>
     <sequence>
      <element name="a" type="int"/>
      <element name="b" type="int"/>
     </sequence>
    </complexType>
   </element>
   <element name="addResponse">
    <complexType>
     <sequence>
      <element name="addReturn" type="int"/>
     </sequence>
    </complexType>
   </element>
   <element name="subtract">
    <complexType>
     <sequence>
      <element name="a" type="int"/>
      <element name="b" type="int"/>
     </sequence>
    </complexType>
   </element>
   <element name="subtractResponse">
    <complexType>
     <sequence>
      <element name="subtractReturn" type="int"/>
     </sequence>
    </complexType>
   </element>
   <element name="InvalidCredentialsException">
    <complexType>
     <sequence>
      <element name="faultString" type="string"/>
      <element name="faultActor" type="string"/>
      <element name="faultCode" type="string"/>
     </sequence>
    </complexType>
   </element>
  </schema>
  </wsdl:types>
  <wsdl:message name="addResponse">
    <wsdl:part name="parameters" element="intf:addResponse"/>
  </wsdl:message>
  <wsdl:message name="InvalidCredentialsException">
    <wsdl:part name="InvalidCredentials" element="intf:InvalidCredentialsException"/>
  </wsdl:message>

  <wsdl:message name="subtractRequest">
    <wsdl:part name="parameters" element="intf:subtract"/>
  </wsdl:message>
  <wsdl:message name="addRequest">
    <wsdl:part name="parameters" element="intf:add"/>
  </wsdl:message>
  <wsdl:message name="subtractResponse">
    <wsdl:part name="parameters" element="intf:subtractResponse"/>
  </wsdl:message>
  <wsdl:portType name="Calculator">
    <wsdl:operation name="add">
      <wsdl:input name="addRequest" message="intf:addRequest"/>
      <wsdl:output name="addResponse" message="intf:addResponse"/>
      <wsdl:fault name="InvalidCredentialsFault" message="intf:InvalidCredentialsException"/>
    </wsdl:operation>
    <wsdl:operation name="subtract">
      <wsdl:input name="subtractRequest" message="intf:subtractRequest"/>
      <wsdl:output name="subtractResponse" message="intf:subtractResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="CalculatorSoapBinding" type="intf:Calculator">
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="add">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="addRequest">
        <wsdlsoap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="addResponse">
        <wsdlsoap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="InvalidCredentialsFault">
        <wsdlsoap:fault name="InvalidCredentialsFault" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
    <wsdl:operation name="subtract">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="subtractRequest">
        <wsdlsoap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="subtractResponse">
        <wsdlsoap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="CalculatorService">
    <wsdl:port name="Calculator" binding="intf:CalculatorSoapBinding">
      <wsdlsoap:address location="http://localhost:9080/ForPEAS/services/Calculator"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
When I do this and run the service, the exception thrown in the service is added as SOAPFault to the body but not as faultCode, faultString and faultActor. The sample response soap is shown below.
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns-322385827="http://docws.syndeopeas.com" xmlns="">ns-322385827:&gt;InvalidCredentialsException</faultcode>
<faultstring xmlns=""><![CDATA[com.syndeopeas.docws.InvalidCredentialsException]]></faultstring>
<detail xmlns=""><InvalidCredentialsException xmlns="http://docws.syndeopeas.com"> <faultString>InvalidCredentials</faultString><faultActor>you</faultActor><faultCode>123</faultCode></InvalidCredentialsException></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
 
The elements of the exception are going into the details. Is there a way by which when this exception is thrown, the elements of SOAPfault get set to these values?
 
Thanking you in advance,
 
Regards,
Terance.


Yahoo! FareChase - Search multiple travel sites in one click.

Reply via email to