[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xmlblaster] .NET xmlrpc code



Well since I cannot get the activex bridge to work, I played around with
XMLRPC, since it seems how many of the other clients, python, perl, tcl,
were implemented.

The first implementation of a .net xmlrpc library that I found was at:
http://www.xml-rpc.net

At first, I thought this was the only, or official implementation...but
it looks like there are more.

Anyway, I downloaded the xmlrpc dll, and this code works...of course I
punked out on the .get because the CLS specification doesn't really
handle jagged arrays or arrays of differing types...however, I also know
it can be handled as an object in some way, because the IDE handles it
just fine, I can see all the values in the debugger.  

But, that reminds me, if anyone does play around with this, it doesn't
always connect in DEBUG mode, giving some kind of webservices error, but
it seems to be only an issue in DEBUG, working just fine in deploy mode.

Oh golly, I will have to learn programming lingo someday...anyway good
luck.

Imports System
Imports CookComputing.XmlRpc
Module Module1

    <XmlRpcUrl("http://localhost:8080/";)> _
Public Class xmlBlasterRPCProxy
        Inherits XmlRpcClientProtocol
        <XmlRpcMethod("authenticate.login")> _
    Public Function AuthenticateLogin(ByVal UserName As String, _
                                      ByVal Password As String, _
                                      ByVal ConnectQOS As String, _
                                      ByVal SecretSession As String) _
                                      As String
            Return Invoke("AuthenticateLogin", New Object() {UserName,
Password, ConnectQOS, SecretSession})
        End Function

        <XmlRpcMethod("xmlBlaster.get")> _
Public Function xmlBlasterGet(ByVal SecretSession As String, _
                              ByVal queryKey As String, _
                              ByVal DontKnowReally As String) _
                              As Array()
            Return Invoke("xmlBlasterGet", New Object() {SecretSession,
queryKey, DontKnowReally})
        End Function

        <XmlRpcMethod("authenticate.logout")> _
Public Function AuthenticateLogout(ByVal SecretSession As String) _
                      As String
            Return Invoke("AuthenticateLogout", New Object()
{SecretSession})
        End Function

    End Class


    Sub Main()
        Dim proxy As New xmlBlasterRPCProxy
        Dim SecretSession As String
        Dim response As Array
        Dim queryKey As String
        Dim signatures As Array()


        ' Connect to the server
        SecretSession = proxy.AuthenticateLogin("guest", "secret",
"<qos></qos>", "")
        Console.WriteLine("Got response:" & SecretSession)

        ' Query the free memory
        queryKey = "<key oid='__cmd:?totalMem'/>"
        signatures = proxy.xmlBlasterGet(SecretSession, queryKey,
"<qos/>")
        ' Ugh, well, I'm just going to grab a quick value
        Console.WriteLine(CStr(signatures(0)(1)(0)))

        ' Leave the server
        SecretSession = proxy.AuthenticateLogout(SecretSession)
    End Sub

End Module