SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb XML-RPC Return Types

    I'm beginning to get familiar with RPC in order to facilitate data communication between a C++ client and a PHP/MySQL server, and XML-RPC is something I've been looking at with particular interest (mainly becuase a large portion of a book I recently bought deals with it).

    However one particularly important question has arisen.

    A fairly large amount of data needs to be passed back to the C++ client. The examples I've seen so far seem to show only one piece of data being returned (such as an integer, or a string). What I'm looking to do is actually send back an entire XML document (which will be dynamically generated by the PHP server) rather than a single parameter.

    Is this possible using XML-RPC, and if so, how might I accomplish this?

    Many thanks,

    Ant
    Regards, Ant.

  2. #2
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An entire XML document is a string in the end, isn't it? What's the problem with just sending it like any other string?
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess that's true. Never thought of that.

    We're quite a way off trying it properely anyway, I just didn't want to start working on using XML-RPC only to discover it woulnd't be able to do what we required

    Thanks for your help.
    Regards, Ant.

  4. #4
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you do a quick prototype in PHP or Python(a "tracer bullet" )? Just make sure to use available libraries and not try to implement XML-RPC from the ground up - it's more of a pain than it looks like at first at the implementation level, but with some of the libraries, it's incredibly easy.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  5. #5
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been reading "Professional PHP4 XML" by Wrox Press, which uses the Usefilinc Library. It seems fairly easy to use, so I'll probably go with that, rather than implementing it all myself.
    Regards, Ant.

  6. #6
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to consider SOAP as an alternative here because it has a "style" called RPC/literal which probably suits what you want. Put another way, if your problem is simply fetching an XML document from a remote web server, don't complicate the problem with an encoded XML messaging protocol, such as XML-RPC or SOAP RPC/Encoded.

    What you could do is write a PHP app where the "method" is defined by the URL and the "params" are either GET or POST variables.

    In other words think about the problem as being one of getting your C++ app to act as a simple web browser (i.e. understands a little HTTP - there must an open source HTTP library in C++ somewhere) then the rest is the same as building a normal web based application, for a human, except you're rendering XML instead of (X)HTML.

    Making some kind of sense?

    Reason why I say this is one of XML-RPC's limitations is it doesn't exchange XML well as a parameter, having no support for XML namespaces. Of course if you really want to do so, perhaps a quick fix is to base64 encode the XML you want to send and regard it as binary.


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
  •