Web Services Guide : Cookbook : How to Send a SOAP Response Using the SstHttpServer Example
How to Send a SOAP Response Using the SstHttpServer Example
Here is how to modify the SstHttpServer example that is shipped with VAST Platform to create a local testing environment in which an SstHttpServer sends back a single SOAP response to any request it receives.
By simply adding two methods to the SstHttpFileServlet, you can send back a hard-coded SOAP response. (The SstHttpServerExample is configured to load and start the file servlet). You need two images running locally, so you will need to start emsrv if you normally work in standalone mode. See the Installation Guide for how to convert a standalone (aka file-io) installation to a team installation and for detailed examples of how to start emsrv on any platform. Below are two examples that will let you start it quickly from a command line prompt:
On Windows:
Open a VAST command prompt window and enter
emsrv -user username –password userpassword –W c:\logfileandpath”,
where logfileandpath is the path to a filename that your user has permission to write to; such as c:\temp\emsrv.log .
On Linux:
Change directories to $TARGETDIR/ bin/emsrv, where $ TARGETDIR is the installation folder, usually /usr/local/VASTPlatform/12.0.0/ and enter
emsrv -lc -lflogfileandpath”,
where logfileandpath is a directory and filename you have permission to write to such as /home/user/temp/emsrv.log.
Note that there is no space between the "-lf" and the logfileandpath.
Start up a development image and load the Server Smalltalk (SST) - HTTP feature.
Open an Application Manager, create a new edition of SstHttpServletSupport and set it as the default.
File in the following two methods:
!SstHttpFileServlet publicMethods !
 
doPost: request
"Process the get request represented by @header. Default processing
entails sending the specified file back to the client."
| contentKey |
 
request header responseHeader fields: request header fields.
contentKey := SstCaseInsensitiveValueHolder for: 'Content-Length'.
request header responseHeader fields at: contentKey put: (self cannedResponse size asString).
 
^self cannedResponse! !
!SstHttpFileServlet publicMethods !
 
cannedResponse
"Return a canned SOAP envelope"
^'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Header>
<Your soap envelope header />
</env:Header>
<env:Body>
<Your soap envelope body />
</env:Body>
</env:Envelope>'
! !
Browse the class SstHttpFileServlet. Modify the method cannedResponse to return your desired SOAP envelope. The method simply returns a string, so replace the template string with a string containing the SOAP envelope you want the server to send back.
Start up the SstHttpServer and its configured servlets by entering: SstHttpServerExample runAt: 'http://:3200/my_service' in: 'c:\web' in a workspace. The server log window should open.
Now you are ready to send the SOAP envelope request to the server.
Modify your wsdl to connect to the local server by modifying the service address:
<wsdl:service name="My_Service">
<wsdl:port name="my_port" binding="my_NamespacePrefix:my_binding">
<soapbind:address location="http://localhost:3200/my_service" />
</wsdl:port>
</wsdl:service>
Start up another development image, and load the web services feature. Deploy your wsdl and invoke the service.
Set a breakpoint in SstWSHttpDispatchHandler>>invoke: if you wish to stop and inspect the contents of the request envelope you are sending out, and verify that the canned response is returned.
Last modified date: 02/12/2021