Wednesday, November 22, 2006

Smalltalk to the rescue

Well, it finally took Smalltalk to find out the answer to yesterday's question.

It's enough to simply raise the exception in the method that implements the web service API. ActionWebService takes care of converting this exception into a SOAP fault message.

Five lines of code in the VisualWorks workspace was all it took:

wsdlClient := WsdlClient new loadFrom: 'http://localhost:3000/hello/service.wsdl' asURI.
soapRequest := SoapRequest new.
soapRequest port: wsdlClient config anyPort.
soapRequest smalltalkEntity: (Message selector: #Hello ).
soapResponse := soapRequest value.

Executing this snippet produced a Smalltalk exception; step into the debugger, inspect the transportEntity object, and see the SOAP fault message in all its glory.