How do I form an XML-RPC query to a remote server?
Hi all, I'm experimenting with collating data from a remote database that uses XML-RPC. I can send it messages like;
import xmlrpclib medweb = xmlrpclib.Server("http://bogus.server.com") medweb.getImages('scar') '<?xml version="1.0" encoding="ISO-8859-1" ?>\015\012\011<data>\015\012\011\011<title>Medwebb Images</title> \0
(lots of stuff snipped) But I just can't figure out how to send the XML version of the same query, ie <?XML VERSION="1.0"?> <methodCall> <methodName>getimages</methodName> <params> <param> <value><string>scar</string></value> </param> </params> </methodCall> to the server. I've got a nasty feeling that when I get told how to do this, I'm going to slap my forehead bloody hard.... As you can see the data is returned in XML format, and whilst I'm fine with Python code for XML parsing (usually use sgmlop), I'm a bit lost on where to start here. An External Method seems the best way, but I'd like the received wisdom on this. Ta muchly, tone ------ Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/ The Medical School, Newcastle University Tel: +44 191 222 5116 A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope
Tony McDonald wrote:
Hi all, I'm experimenting with collating data from a remote database that uses XML-RPC.
I can send it messages like;
import xmlrpclib medweb = xmlrpclib.Server("http://bogus.server.com") medweb.getImages('scar') '<?xml version="1.0" encoding="ISO-8859-1" ?>\015\012\011<data>\015\012\011\011<title>Medwebb Images</title> \0
(lots of stuff snipped)
But I just can't figure out how to send the XML version of the same query, ie <?XML VERSION="1.0"?> <methodCall> <methodName>getimages</methodName> <params> <param> <value><string>scar</string></value> </param> </params> </methodCall>
to the server.
How does it fail? Did you set the right content type (text/xml I think?)? Why do you want to send a hand built query to the server? That's what xmlrpclib is for. -Michel
I've got a nasty feeling that when I get told how to do this, I'm going to slap my forehead bloody hard....
Do what I do, where a helmet to work.
On 15/11/00 5:58 pm, "Michel Pelletier" <michel@digicool.com> wrote:
Tony McDonald wrote:
Hi all, I'm experimenting with collating data from a remote database that uses XML-RPC.
I can send it messages like;
import xmlrpclib medweb = xmlrpclib.Server("http://bogus.server.com") medweb.getImages('scar') '<?xml version="1.0" encoding="ISO-8859-1" ?>\015\012\011<data>\015\012\011\011<title>Medwebb Images</title> \0
(lots of stuff snipped)
But I just can't figure out how to send the XML version of the same query, ie <?XML VERSION="1.0"?> <methodCall> <methodName>getimages</methodName> <params> <param> <value><string>scar</string></value> </param> </params> </methodCall>
to the server.
How does it fail? Did you set the right content type (text/xml I think?)?
Thanks for the reply Michel, Yes the content type is text/xml, but I guess I'm doing something else wrong.
Why do you want to send a hand built query to the server? That's what xmlrpclib is for.
Oh definitely, but I'm trying to do it this way as I think the queries may get more complex...
-Michel
I've got a nasty feeling that when I get told how to do this, I'm going to slap my forehead bloody hard....
Do what I do, where a helmet to work.
I like that! :) ------ Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/ The Medical School, Newcastle University Tel: +44 191 222 5116 A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope
On Wed, 15 Nov 2000, Tony McDonald wrote:
Hi all, I'm experimenting with collating data from a remote database that uses XML-RPC.
I can send it messages like;
import xmlrpclib medweb = xmlrpclib.Server("http://bogus.server.com") medweb.getImages('scar')
That looks right...
'<?xml version="1.0" encoding="ISO-8859-1" ?>\015\012\011<data>\015\012\011\011<title>Medwebb Images</title> \0
(lots of stuff snipped)
That doesn't ... I don't think they have a well formed XML-RPC document, so xmlrpclib can't parse it...
But I just can't figure out how to send the XML version of the same query, ie
xmlrpclib handles the marshaling/un-marshaling to xml/from python for you...
<?XML VERSION="1.0"?> <methodCall> <methodName>getimages</methodName> <params> <param> <value><string>scar</string></value> </param> </params> </methodCall>
to the server.
xmlrpc lib is already constructing this...or it should be,,,
I've got a nasty feeling that when I get told how to do this, I'm going to slap my forehead bloody hard....
See above :-)
As you can see the data is returned in XML format, and whilst I'm fine with Python code for XML parsing (usually use sgmlop), I'm a bit lost on where to start here. An External Method seems the best way, but I'd like the received wisdom on this.
Again, See above...xmllib should handle all the marshaling from xml to python data types for you...I'm not sure what it does in the case of an ill formed document, it may jsut pass back the date to you, in this case the xml you are recieveing...
Ta muchly, tone ------ Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/ The Medical School, Newcastle University Tel: +44 191 222 5116 A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- ...EAM... edwardam@home.com edwardam@handhelds.org ----------------------- 'It's because crappy programs offend me.' --Eric Raymond
On 16/11/00 7:10 am, "Edward Muller" <edwardam@home.com> wrote:
On Wed, 15 Nov 2000, Tony McDonald wrote:
Hi all, I'm experimenting with collating data from a remote database that uses XML-RPC.
I can send it messages like;
import xmlrpclib medweb = xmlrpclib.Server("http://bogus.server.com") medweb.getImages('scar')
That looks right...
Yup, that bit works! :)
'<?xml version="1.0" encoding="ISO-8859-1" ?>\015\012\011<data>\015\012\011\011<title>Medwebb Images</title> \0
(lots of stuff snipped)
That doesn't ... I don't think they have a well formed XML-RPC document, so xmlrpclib can't parse it...
I think that is ok XML. The \015\012 are just LF-CRs and are ignored.
But I just can't figure out how to send the XML version of the same query, ie
xmlrpclib handles the marshaling/un-marshaling to xml/from python for you...
Absolutely, and it works fine when I do it from a Python prompt.
<?XML VERSION="1.0"?> <methodCall> <methodName>getimages</methodName> <params> <param> <value><string>scar</string></value> </param> </params> </methodCall>
to the server.
I'm really just trying to get a Zope equivalent of the Userland 'debugger' at <http://frontier.userland.com/stories/storyReader$1077> as I think these queries may get more complex.
xmlrpc lib is already constructing this...or it should be,,,
I've got a nasty feeling that when I get told how to do this, I'm going to slap my forehead bloody hard....
See above :-)
I'll take Michels advice and wear a helmet to work! :) Cheers, Tone. ------ Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/ The Medical School, Newcastle University Tel: +44 191 222 5116 A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope
Tony McDonald wrote:
Hi all, I'm experimenting with collating data from a remote database that uses XML-RPC.
I can send it messages like;
import xmlrpclib medweb = xmlrpclib.Server("http://bogus.server.com") medweb.getImages('scar') '<?xml version="1.0" encoding="ISO-8859-1" ?>\015\012\011<data>\015\012\011\011<title>Medwebb Images</title> \0
(lots of stuff snipped)
But I just can't figure out how to send the XML version of the same query, ie <?XML VERSION="1.0"?> <methodCall> <methodName>getimages</methodName> <params> <param> <value><string>scar</string></value> </param> </params> </methodCall>
to the server.
I've got a nasty feeling that when I get told how to do this, I'm going to slap my forehead bloody hard....
As you can see the data is returned in XML format, and whilst I'm fine with Python code for XML parsing (usually use sgmlop), I'm a bit lost on where to start here. An External Method seems the best way, but I'd like the received wisdom on this.
this probably isn't your problem, but in your above example getimages looks like it should be getImages. i'm not sure why you want work by hand on the xml-processing, since xmlrpclib already exists. if you want to debug your setup you can use shane hathaway's tcpwatch as a proxy which show you what goes out on the wire. as for the location of such code, it depends on what you're doing with the results, i think the choices are between a product and an external method. kapil
participants (4)
-
Edward Muller -
Ender -
Michel Pelletier -
Tony McDonald