[plt-scheme] Implementing web services
xml-rpc looked like exactly what I need, though I haven't had much
time to work on this and my slow progress isn't helping. I figure
it's time to ask why this isn't working. I've set up the sample
servlet and client as follows:
/collects/web-server/default-default-web-root/servlets/math.ss
> (module math mzscheme
> (require (planet "xmlrpc-module-servlet.ss"
> ("schematics" "xmlrpc.plt" 2)))
> (provide interface-version manager timeout start)
> (define (add x y) (+ x y))
> (add-handler 'math.add add)
> )
~/Documents/Scheme/xmlrpc/add_client.scm
> (module add_client mzscheme
> (require (planet "xmlrpc.ss" ("schematics" "xmlrpc.plt" 2 1)))
> (provide (all-defined))
> (define math (xmlrpc-server "localhost:8080/servlets/math.ss"
> 8080 "RPC2"))
> (define add (math "math.add"))
> (add 1 1)
> )
The xmlrpc-server call seems very wrong to me, but it's the only way
I could get even close. By 'close' I mean that it causes an error on
the server, which returns a HTTP 500 and prints this on the terminal
running plt-web-server as a background process:
> Servlet didn't load:
> open-input-file: cannot open input file: "/Applications/PLT Scheme
> v370/collects/web-server/default-web-root/./servlets/math.ss:
> 8080" (No such file or directory; errno=2)
>
>
> === context ===
> /Applications/PLT Scheme v370/collects/mred/private/snipfile.ss:
> 253:2: build-input-port
> /Applications/PLT Scheme v370/collects/mred/private/snipfile.ss:
> 207:2: text-editor-load-handler
> /Applications/PLT Scheme v370/collects/web-server/dispatchers/
> dispatch-servlets.ss:308:4: load-servlet/path
> /Applications/PLT Scheme v370/collects/web-server/dispatchers/
> dispatch-servlets.ss:291:4: reload-servlet-script
> ...ivate/cache-table.ss:38:46
> /Applications/PLT Scheme v370/collects/web-server/private/cache-
> table.ss:30:11
> cache-table-lookup!
> select-handler/no-breaks
> select-handler/no-breaks
> select-handler/no-breaks
> dispatcher?
> dispatcher?
> /Applications/PLT Scheme v370/collects/web-server/private/dispatch-
> server-unit.ss:67:10: connection-loop
If I define math as (define math (xmlrpc-server "http://localhost:
8080/servlets/math.ss")) which seems to be valid, I get the following
error in DrScheme from the client:
> "protocol.ss" broke the contract
> (case->
> (-> url? bytes? input-port?)
> (-> url? bytes? (listof string?) input-port?))
> on post-impure-port; expected <url?>, given: "http://localhost:8080/
> servlets/math.ss"
I feel like I need a bit too much hand holding, but any tips would be
appreciated.
-IR
On Aug 10, 2007, at 9:09 AM, Noel Welsh wrote:
> On 8/9/07, Isaac Raway <isaac.raway at gmail.com> wrote:
>> To clarify, this is different from the recent request for how to go
>> about generating a website. What I'm looking for is a way to
>> implement, say, a module, export some procedures from it, and have
>> those accessible through a stub object on the client side or directly
>> called by the view of the dynamic web interface.
>
> You might be interested in the xml-rpc library on Planet. For more
> general information check out our recent experience report, linked
> from http://www.untyped.com/untyping
>
> HTH,
> Noel