Wednesday, May 2, 2012

Understanding WSDL Faults

Understanding WSDL Faults

Consider the WSDL with  portType and operations as shown below

< portType name="Sample" >
    < operation name="sayHello" >
      < input message="tns:sayHello"/ >
      < output message="tns:sayHelloResponse"/ >
    < /operation >
    < operation name="addNum" >
      < input message="tns:addNum"/ >
      < output message="tns:addNumResponse"/ >
    < /operation >
    < operation name="subNum" >
      < input message="tns:subNum"/ >
      < output message="tns:subNumResponse"/ >
    < /operation >
  < /portType >
     
   

 


" In the above example each operation has input and output message. For each operation we can add the fault message it returns. The message definition is shown below

 
< message name="SayHelloFaultMessage" >
 < part name="error" type="xs:string" / >
 < /message >

 < message name="AddNumFaultMessage" >
 < part name="error" type="xs:string" / >
 < /message >

 < message name="SubNumFaultMessage" >
 < part name="error" type="xs:string" / >
 < /message >
     

     
After adding the fault the porType is shown below
   
  < portType name="Sample" >
    < operation name="sayHello" >
      < input message="tns:sayHello"/ >
      < output message="tns:sayHelloResponse"/ >
    < fault name="fault" message="tns:SayHelloFaultMessage" / >

    < /operation >
    < operation name="addNum" >
      < input message="tns:addNum"/ >
      < output message="tns:addNumResponse"/ >
    < fault name="fault" message="tns:AddNumFaultMessage" / >

    < /operation >
    < operation name="subNum" >
      < input message="tns:subNum"/ >
      < output message="tns:subNumResponse"/ >
    < fault name="fault" message="tns:SubNumFaultMessage" / >

    < /operation >
  < /portType >


Note the following while adding fault:
WSDL does not require that we use unique fault names within the namespace used
to define the operation. In other words, that faults that have the same name and are
defined within the same namespace will be considered as the same fault in BPEL.
Keep this in mind when designing services that can potentially become partners
of BPEL business processes, because this can lead to conflicts in fault handling
during execution.

In the above we have given unique name so that all the faults are considered as different