Functorise the client module so it can be used with Lwt

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Fix jsonrpc so that it marshalls the reponse in json rather than xml

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Merge pull request #958 from jonludlam/lwt-client-new

Lwt client new