I have a flow service with a defined set of input and output and this flow service is exposed as a web service. Under normal processing of the flow service, the defined output is returned to the service client. However, during the execution of flow service, under certain circumstances, I need to construct a custom response (consider this as a Web Service Fault message) and return this message back to the client. In this case, my custom message will be different from the output defined for the flow service & eventually the web service.
Can this be done in webMethods? I mean a web service should have a contract (defined set of input & output) but can the service return something else?
Why not just declare an “error” value for example in your output which is not mandatory, and set it if there is an error ? Because how will your consumers know where your “Web Service Fault message” is set ?
There are different ways to do this.
If you want to send the custom message as a response without soap fault, then add a field in the output and set the custom response to that field. This field you can use to send the response back to the webService client. In this case, even though its not a success response, but still webService call will be success.
Otherwise you can throw a exception with the custom respone and that message will be part of the SOAP Fault. Exception needs to be handled by the webService client.