[plt-scheme] Confusing web-server interaction

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sun Apr 5 09:58:57 EDT 2009

On Sun, Apr 5, 2009 at 6:55 AM, Matt Jadud <jadudm at gmail.com> wrote:
> Hi all,
> (This is probably a question for Jay, though...)
> I don't update the XML-RPC library as often as I should. Perhaps if I
> was more diligent, it would be easier to keep up on how the internals
> have changed.
> On the server side, I apparently no longer need "response.ss" from the
> "private" portion of the web-server.

Yes, you'll using web-server/http. The signature of make-response/full
is different though, so you'll need to update the code.

> After getting rid of this require
> from "server-core.ss" in the library, things run, but I get the
> following error from within the web-server:
> ../apps/plt413/collects/web-server/dispatchers/dispatch-files.ss:27:18:
> string-ref: expects type <non-negative exact integer> as 2nd argument,
> given: -1; other arguments were: ""

This is a Web server bug that is now fixed in SVN. The problem is that
an empty URL is being browsed to and when the path is added to it, it
is a directory, so the server is testing if the URL "looks like" a
directory (by having a trailing slash) --- if it does, we show an
index, otherwise, we add the / and redirect. I expect, however, that
you don't really want this to happen at all.

> I haven't really dug into things since the insta and dispatch
> libraries were rolled into the web-server collection itself. I'm not
> sure what I should be doing in the XML-RPC library to avoid this
> error.
> What follows are my server and client code. I'm wondering: do I need a
> custom dispatcher, or should I be able to run the XML-RPC library as a
> simple servlet, given that it provides "interface-version", "manager",
> "timeout", and  "start"? Either way, I thought asking a question would
> be the quicker route to getting things rolling again, as there are
> enough new things that I'm not quite sure where best to start.

You do *not* need to write a dispatcher for this.

Also, the *timeout* export is ignored when interface-version is 'v2.

And, all these exports are ignored when you are using serve/servlet.
It has an additional #:manager keyword argument to set what the
manager should be.

> Cheers,
> Matt
> #lang scheme
> (require (planet schematics/xmlrpc:4:0/xmlrpc-module-servlet)

This hasn't been updated on planet so it errors for different reasons
than you describe in the email.

>         web-server/servlet
>         web-server/servlet-env)
> (define (add x y) (+ x y))
> (add-handler 'math.add add)
> (serve/servlet start
>               #:port 9000
>               #:servlet-path "/RPC"
>               #:launch-browser? false
>               )
> #lang scheme
> (require (planet schematics/xmlrpc:4:0/xmlrpc))
> (define local (xmlrpc-server "localhost" 9000 "/RPC"))
> (define remote-add (local 'math.add))
> (remote-add 3 5)
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.