[Haskell] Announce: Haskell XML-RPC library
Bjorn Bringert
d00bring at dtek.chalmers.se
Mon Mar 15 23:40:50 EST 2004
Announcement: Haskell XML-RPC library
----------------------------------------------------------------------
I have written a Haskell XML-RPC client and server library which is
available from:
http://www.dtek.chalmers.se/~d00bring/haskell-xml-rpc/
XML-RPC (http://www.xmlrpc.com/) is "remote procedure calling using HTTP
as the transport and XML as the encoding. XML-RPC is designed to be as
simple as possible, while allowing complex data structures to be
transmitted, processed and returned."
Library features:
- Easy to use interface, see code examples below.
- Lower-level interface for explicit conversion between XML-RPC and
Haskell types, e.g. to support heterogeneous arrays and structs.
- Support for XML-RPC introspection in both client and server. Remote
method declarations can be generated by using introspection, see
test/make-stubs.hs.
- Support for HTTP authentication.
Code examples:
This is a simple CGI-based server with only one method that takes two
integers and returns their sum:
> import Network.XmlRpc.Server
>
> add :: Int -> Int -> IO Int
> add x y = return (x + y)
>
> main = cgiXmlRpcServer [("examples.add", fun add)]
This is a client that calls the method implemented by the server above
and prints the result:
> import Network.XmlRpc.Client
>
> server = "http://localhost/~bjorn/cgi-bin/simple_server"
>
> add :: Int -> Int -> IO Int
> add = remote server "examples.add"
>
> main = do
> let x = 4
> y = 7
> z <- add x y
> putStrLn (show x ++ " + " ++ show y ++ " = " ++ show z)
Requirements:
- GHC >= 6.01 or Hugs >= Nov2003
- HaXml >= 1.10
All comments, suggestions, bug reports and flames are welcome.
Yours truly,
Bjorn Bringert
More information about the Haskell
mailing list