How To Send a SOAP Response Using the HttpServer Example

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

How To Send a SOAP Response Using the HttpServer Example

Postby Diane Engles » Tue May 12, 2009 10:37 am

I am going to be posting several How-To's and Debugging Tips over the next few weeks that will be included in the Cookbook section of the Web Services Guide. It takes some time to rebuild and upload the documentation in the new format, so I wanted to make information available as soon as possible.

Here is how to modify the HttpServer example that is shipped with versions 7 and 8 of the product to create a local testing environment in which an HttpServer 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:\logfilepath”, where logfilepath is the path to a filename that your user has permission to write to; for example c:\temp\emsrv.log

On Linux: Change directories to /usr/local/VASmalltalk/8.0/bin/emsrv and enter “emsrv -lc -lflogfilepath”, where logfilepath 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 logfile path.

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:

Code: Select all
!SstHttpFileServlet publicMethods !

doPost: request
   "Process the get request represented by @header.  Default processing
   entails sending the specifed 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 !

   "Return a canned SOAP envelope"
^'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<env:Envelope xmlns:env=""
      <Your soap envelope header />
      <Your soap envelope body />
! !

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 HttpServer 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" />

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.
Diane Engles
Posts: 66
Joined: Mon Oct 16, 2006 2:40 pm

Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest