The Wayback Machine - http://web.archive.org/web/19980131200310/http://www.scripting.com:80/frontier5/xml/rpc/testScript.html

Powerful, cross-platform web scripting.


Home Page

The Plan

Pointers

Site Outline

Scripting News

Still Diggin!

Frontier 5 and XML: RPC Test Script

This is a fat page containing a test script that calls the XML server running on the LAN at www.scripting.com.

It's designed to run in Frontier 5/Win, but it can easily be adapted to run in any other HTTP-aware programming environment.

In fact, with Alan German's help, I just adapted it to run in the Mac version of Frontier 5.

Listing

local (server = "206.204.24.10")
local (port = 81)
local (query = string (workspace.xmltest.query))
local (command = "")
bundle //build the HTTP request
 on add (s)
 command = command + s + "\r\n"
 add ("POST /xmlGateway HTTP/1.0")
 add ("User-Agent: Frontier/" + Frontier.version () + " (" + sys.os () + ")")
 add ("Host: " + server)
 add ("Content-Type: text/xml")
 add ("Content-length: " + sizeOf (query))
 add ("") //blank line
 add (query)
local (stream = tcp.openStream (server, port))
wp.newtextobject (command, @workspace.xmltest.command)
tcp.writeStream (stream, command)
local (s = "")
local (timeout = clock.ticks () + (60 * 3))
loop
 local (bytespending)
 case tcp.statusStream (stream, @bytespending)
 "CLOSING"
 "CLOSED"
 "INACTIVE"
 break
 "DATA"
 s = s + tcp.readStream (stream, bytespending)
 if clock.ticks () > timeout
 s = ""
 break
tcp.closeStream (stream)
wp.newtextobject (s, @workspace.xmltest.queryResult)
edit (@workspace.xmltest.queryResult)

Query

As you can see, it's just an HTTP client.

Here's the HTTP request it sends:

POST /xmlGateway HTTP/1.0

User-Agent: Frontier/5.0b5 (WinNT)

Host: 206.204.24.10

Content-Type: text/xml

Content-length: 300

<?XML VERSION="1.0"?> <remoteProcedureCall> <header> <rpcVersion>1.0a1</rpcVersion> <docs>http://www.scripting.com/frontier5/xml/rpc/</docs> </header> <procedureName>getStateName</procedureName> <param> <name>stateNum</name> <value>14</value> </param> </remoteProcedureCall>




© Copyright 1996-97 UserLand Software. This page was last built on 1/15/98; 5:02:56 PM. It was originally posted on 1/14/98; 2:12:38 PM. Webmaster: dave@scripting.com.