. .

st4u

ST 4U 275: Deploying Web Services in VA Smalltalk

August 24, 2012 10:11:45.751

Today's Smalltalk 4 You puts the pieces together on WS* in VA Smalltalk - we'll deploy our simple example. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Web Services.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll go back to the Web Services example we had been building in VA Smalltalk. To get started, recall the simple example we'll be using - a "counter" class:

Example

The first thing we'll need is a server to listen on a port. Start that this way:


server := SstHttpServerExample
        runAt: 'http://:7777'

        in: ('C:\Program Files\Instantiations\VA Smalltalk\8.5\xml').

The file path should be to wherever you have VA looking for the XML files, as specified in your ini file.

If you do that correctly, you should see a console window like the following appear:

Listener

That window will log what's happening, so if anything goes wrong, you can examine the results. Next, you'll need to deploy the container for your WS* application:


SstWSContainer clearAll.

"create server container" 

[ | aContainer  | 
aContainer := SstWSContainer
        createContainerNamed:  'ServerContainer'
         using: (SstWSContainerConfiguration defaultConfiguration).
        aContainer startUp.
        aContainer deploy:   'http://localhost:7777/CounterServer.xml'] fork.


You should see some reporting in the server log after doing this:

Listener

Now, we are ready to actually set up and invoke the code through a client. Here's the code for that:


"create client container" 

[ "| cContainer counterService |"
    cContainer := SstWSContainer
        containerNamed:  'ClientContainer'
        ifNone: [SstWSContainer createContainerNamed: 'ClientContainer'].
        cContainer deploy:   'http://localhost:7777/CounterClient.xml'.


   "two ways to retrieve the service from the client" 

   "counterService := (SstWSContainer 
		containerNamed: 'ClientContainer') allServices first. "
   counterService := (SstWSContainer containerNamed: 'ClientContainer') 
	serviceNamed: 'Counter' inNamespace: 'http://www.Counter.com/Counter-impl'.

   "result should be the string returned from the Counter class methods" 

   (counterService addValue: '5') inspect.
   (counterService subtractValue: '10' ) inspect  ] fork.

Notice the lines at the end where we invoke the service. If everything went well, you'll see two signs that it all worked - lines in the Transcript from the code, and more entries in the log:

Worked

Worked

Finally, if you want to experiment with the example, you may need the following "clean up" code - to clear out your listeners and start fresh:


(SstWSContainer containerNamed: 'ServerContainer') shutDown.

(SstWSContainer containerNamed: 'ClientContainer') shutDown

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

Enclosures:
[st4u275-iPhone.m4v ( Size: 4509257 )]

posted by James Robertson

 Share Tweet This