Search code examples
exceptionsoapwsdlsoafault

Throw exception from one-way operation


Assume that you have the following operation:

void AddCustomer(Customer)

(i.e. a Customer object as input and no output)

Complying to WS-I BP 1.1 you are not allowed to define fault messages for one-way operations [1]. However, you may want to throw an exception in case, for example, the customer is a duplicate. How would you achieve this? Defining the operation as a request/response with an empty response signaling that the operation succeeded? Not that pretty in my opinion... Maybe you know another way? I mean: within a java/.net program you still want to be able to throw exceptions also for void-methods...

Example:

<operation name="AddCustomer">
    <input message="tns:AddCustomerRequest"/>
    <output message="tns:AddCustomerResponse"/>
    <fault name="DuplicateCustomer" message="tns:DuplicateFault"/>
</operation>

where AddCustomerResponse would be an empty sequence.

[1] http://www.w3.org/TR/wsdl#_porttypes


Solution

  • According to the wsdl 1 specification there is no solution for this.