[Vala] Genie xmlrpc-c bindings test



Trouble again guys...

I have attempted to convert pancake's xmlrpc-c test client that I modified to use a call to the webERP PHP demo server's XML-RPC api. It is using pancake's xml-rpc-c bindings

The code fails with:

# valac --pkg=xmlrpc --Xcc=-lxmlrpc_client xmlrpc-c_test.gs
/initrd/mnt/dev_save/my-documents/genie_programs/xmlrpc-c_test.vala.c: In function '_xmlrpc_INCREF0': /initrd/mnt/dev_save/my-documents/genie_programs/xmlrpc-c_test.vala.c:90: error: void value not ignored as it ought to be
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)


The following genie code (it worked ok with Pancake's vala code)

[indent=4]
/* Build with "valac  --pkg=xmlrpc  --Xcc=-lxmlrpc_client xmlrpc-test.gs */
uses
    XmlRpc
        
init
    /*variables for the setup of the xml-rpc session */
    ProgramName:string = "Genie XML-RPC Test Program"
    ProgramVersion:string = "0.00001"

   /*XmlRpc objects required for the xml-rpc session defined */
XClient: XmlRpc.Client /*This is the client object created by the Client Create */
    var XEnv = XmlRpc.Env() /* This is the XmlRpc Env struct */
    XReturnValue: XmlRpc.Value
        
    print "Genie xmlrpc test program\n"

    /*initialise the xml-rpc client session */
    XmlRpc.Client.init (0, ProgramName, ProgramVersion)
XmlRpc.Client.create (XEnv, 0, ProgramName, ProgramVersion, null, 0, out XClient)

    Server:string  = "http://www.weberp.org/weberp/api/api_xmlrpc.php";
    var XServer = new XmlRpc.ServerInfo (XEnv, Server)

    if XEnv.fault_occurred
print "Setting the properties of the xml-rpc server failed with the message: %s fault code: %d", XEnv.fault_string, XEnv.fault_code
        Thread.exit (null)
        
    /*Initialise an array to hold the Xml-rpc method parameters */
    var XQuery = new XmlRpc.Array(XEnv)
        
    /*XML-RPC call the method
      weberp.xmlrpc_GetStockBalance
this method requires 3 strings as parameters - all put into the new XQuery array in sequence 0 , 1, 2
                item code,
                username
                password*/
                                                                                                
    XQuery.append_item (XEnv,XEnv.string_new ("DVD-TOPGUN"))
    XQuery.append_item (XEnv, XEnv.string_new ("admin"))
    XQuery.append_item (XEnv, XEnv.string_new ("weberp"))
    /* Now do the xml-rpc call */       
XClient.call2 (XEnv, XServer, "weberp.xmlrpc_GetStockBalance", XQuery, out XReturnValue)

    if XEnv.fault_occurred
        print "Oops.. fault happened (%s)\n", XEnv.fault_string
    else
print ("type = %d (struct = %d)\n", XReturnValue.type(), XmlRpc.Type.STRUCT)
        print_value (XEnv, XReturnValue);
/*end of main program */

def print_value(XEnv:XmlRpc.Env, XValue:XmlRpc.Value)
    i:int =0
    XItem:XmlRpc.Value
    XKey:XmlRpc.Value
    XKeyValue:XmlRpc.Value
    XArray:XmlRpc.Array
    ArraySize:int
    XStruct:XmlRpc.Struct
    ReturnedString: string
    ReturnedNumber:int
    Key: string
    KeyValue: string
    DataType:XmlRpc.Type = XValue.type ()
    case (DataType)
        when XmlRpc.Type.ARRAY
            XArray =  (XmlRpc.Array*) XValue
            ArraySize = XArray.size(XEnv)
            print "Array [%d] = {\n", ArraySize
            while i < ArraySize
                XItem = XArray.get_item (XEnv, i)
                print "  array[%d] = ", i
                /* function calls itself recursively */
                print_value (XEnv, XItem)
                i++
            print "}\n"
        when XmlRpc.Type.INT
            XEnv.read_int(XValue, out ReturnedNumber);
print "The value returned is an integer: (%d)\n", ReturnedNumber
        when XmlRpc.Type.STRING
            XEnv.read_string (XValue, out ReturnedString);
            print "The value returned is a string: (%s)\n", ReturnedString
        when XmlRpc.Type.STRUCT
            XStruct = (XmlRpc.Struct) XValue
            print "Struct size: %d\n", XStruct.size(XEnv)
            while i < XStruct.size(XEnv)
XEnv.struct_get_key_and_value(XValue,i, out XKey, out XKeyValue)
                XEnv.read_string(XKey,out Key)
                XEnv.read_string(XKeyValue,out KeyValue)
                print "  Struct %s -> %s ",Key, KeyValue
                i++
        default
            print "Unknown data type %d\n", DataType



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