HTTP Post Request

Kushal Kumaran kushal.kumaran+python at gmail.com
Mon May 10 22:06:53 EDT 2010


On Mon, May 10, 2010 at 8:26 PM, kaklis at gmail.com <kaklis at gmail.com> wrote:
> On May 10, 10:22 am, Kushal Kumaran <kushal.kumaran+pyt... at gmail.com>
> wrote:
>> On Mon, May 10, 2010 at 7:30 PM, kak... at gmail.com <kak... at gmail.com> wrote:
>> > Hi to all, i want to ask you a question, concerning the best way to do
>> > the following as a POST request:
>> > There is server-servlet that accepts xml commands
>> > It had the following HTTP request headers:
>>
>> >            Host: somehost.com
>> >            User-Agent: Jakarta Commons-HttpClient
>> >            Content-Type: text/xml
>> >            Content-Length: 415
>>
>> > and the following request body (reformatted here for clarity):
>>
>> >            <?xml version='1.0'?>
>> >            <methodCall>
>> >              <methodName>search</methodName>
>> >            </methodCall>
>> > How can i send the above to the Listener Servlet?
>> > Thanks in advance
>>
>> Use the xmlrpclib module.
>>
>
> OK, sending headers with xmlrpclib,
> but how do i send the XML message?
>

Your XML message is an XML RPC message.  You will use xmlrpclib like this:

server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
result = server_proxy.search()

The call to server_proxy.search will result in an actual XML RPC
message being sent.

Read up on the xmlrpclib documentation here:
http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
here: http://www.xmlrpc.com/spec

-- 
regards,
kushal



More information about the Python-list mailing list