Cook Computing

XML-RPC From F#

November 2, 2008 Written by Charles Cook I recently downloaded the F# September CTP from the F# Developer Center and experimented with some code to make an XML-RPC call using XML-RPC.NET.

#light

open CookComputing.XmlRpc

type Request = { state1 : int; state2 : int; state3 : int; }

[<XmlRpcUrl("http://www.cookcomputing.com/xmlrpcsamples/RPC2.ashx")>]
type IStateName = 
    [<XmlRpcMethod("examples.getStateName")>]
    abstract GetStateName : number: int -> string
    [<XmlRpcMethod("examples.getStateStruct")>]
    abstract GetStateNames : request: Request -> string

let proxy = XmlRpcProxyGen.Create<IStateName>()
let name = proxy.GetStateName(1)
printfn "name is %s" name
let request = { state1 = 1; state2 = 2; state3 = 3; }
let names = proxy.GetStateNames(request)
printfn "names are %s" names