SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP and XMLRPC Web Service

    I am using PHP and Edd Dumbill's XMLRPC code to create a web service for my senior thesis. On my client page I included the server page and on the server page I included xmlrpc.ini and xmlrpcs.ini. My problem is that on the client page I can access the xmlrpcmsg function but after getting a result back I cannot use $len= $val->arraysize() to get the length of the array that was returned from my server. Here is the error as it reads on the web page.

    Fatal error: Call to undefined function: arraysize() in /usr/web/staging/ryanthesis/results.php on line 57

    Thanks in advance to any help.

    Ryan

  2. #2
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Southwest US
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure the included files are actually being included?

    Also do not use relative URLs in your include statements.
    If your client page is in: example.com/client/page.php
    And you server page is in: example.com/server/XMLRPC.php
    And...example.com/server/xmlrpc.ini ...example.com/server/xmlrpcs.ini

    When you include the server page in your client page, then include the ini files from the server page, using:
    include('xmlrpc.ini');
    include('xmlrpcs.ini');

    You are actually saying:
    include('example.com/client/xmlrpc.ini');
    include('example.com/client/xmlrpcs.ini');

    Hope this helps,
    Itshim

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nothing I have tried has worked so far. I'm going to copy some of my code here and post the link as well. Hopefully you will see what I am missing. Ignore the commented out code.
    This is code from my client:

    <?php


    /* Include a file that defines all the xml-rpc "methods" */
    include("web_service_api.php");
    //include ( "xmlrpc.php" );

    /* Define variables to find the rpc server script */
    //$site = "staging.carthage.edu:80";
    //$location = "/ryanthesis/server.php";

    $server = new xmlrpc_client('/ryanthesis/web_service_api.php', 'staging.carthage.edu', 80);
    ?>

    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <body>
    <?PHP

    $type= $_POST["type"];
    $rid= $_POST["rid"];
    $rif= $_POST["rif"];
    $ric= $_POST["ric"];
    $density= $_POST["density"];
    $thickness= $_POST["thickness"];

    if(($type != "") || ($rid != "") || ($rif != "") || ($ric != "") || ($density != "") || ($thickness != ""))
    {
    $myArray=new xmlrpcval(array(
    "type" => new xmlrpcval($type, "string"),
    "rid" => new xmlrpcval($rid, "double"),
    "rif" => new xmlrpcval($rif, "double"),
    "ric" => new xmlrpcval($ric, "double"),
    "density" => new xmlrpcval($density, "double"),
    "thickness" => new xmlrpcval($thickness, "double")), "array");

    //print_r($myArray);

    //$arr["type"] = $type;
    //$arr["rid"] = $rid;
    //$arr["rif"] = $rif;
    //$arr["ric"] = $ric;
    //$arr["density"] = $density;
    //$arr["thickness"] = $thickness;

    //$response = XMLRPC_request($site, $location, "sample.getSampleList()");

    $message = new xmlrpcmsg('sample.getSampleList()', array(new xmlrpcval($myArray, "array")));

    $result = $server->send($message);

    Here is some code from my server:

    <?php
    /* web_service_api.php */

    include ( "xmlrpc.php" );
    include ( "xmlrpcs.php" );

    /* Define an array to name the xmlrpc methods and
    their corresponding PHP functions */



    /* Function for listing sample items, corresponding
    to the sample.getSampleList method */
    function sample_getSampleList() {
    /* Convert the $sample_items array to a set
    of XML-RPC parameters then respond with the XML. */
    $resp = new xmlrpcresp(new xmlrpcval($sample_item, "array"));

    return $resp;
    }

    ?>

    Here is the link to my site:

    http://staging.carthage.edu/ryanthesis/client.php

    Just put a 'W' into the Type field of the form and hit submit.

    Thanks again for any help.

    Ryan

  4. #4
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Southwest US
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I use the form I do not receive the error you mentioned in your first post, I receive:

    Warning: reset(): Passed variable is not an array or object in /usr/web/staging/ryanthesis/xmlrpc.php on line 1681

    Warning: Variable passed to each() is not an array or object in /usr/web/staging/ryanthesis/xmlrpc.php on line 1682

    but in the code you pasted I don't see reset() or each().

  5. #5
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats because those two functions are in the xmlrpc.php that were included. I have been working on this today so I might have changed something around and that could be why you didn't get that error messege. I will try and revert it back so that the error messege shows up again. I will post when I have it ready for you to try.

  6. #6
    SitePoint Member
    Join Date
    May 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, it is back to the point where I got the arraysize() error.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •