Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > HTTP Post Request

Reply
Thread Tools

HTTP Post Request

 
 
kaklis@gmail.com
Guest
Posts: n/a
 
      05-10-2010
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
 
Reply With Quote
 
 
 
 
Kushal Kumaran
Guest
Posts: n/a
 
      05-10-2010
On Mon, May 10, 2010 at 7:30 PM, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> 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.

--
regards,
kushal
 
Reply With Quote
 
 
 
 
kaklis@gmail.com
Guest
Posts: n/a
 
      05-10-2010
On May 10, 10:22*am, Kushal Kumaran <(E-Mail Removed)>
wrote:
> On Mon, May 10, 2010 at 7:30 PM, (E-Mail Removed) <(E-Mail Removed)> 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.
>
> --
> regards,
> kushal


OK, sending headers with xmlrpclib,
but how do i send the XML message?

Thanks
A.K.
 
Reply With Quote
 
Kushal Kumaran
Guest
Posts: n/a
 
      05-11-2010
On Mon, May 10, 2010 at 8:26 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
> On May 10, 10:22*am, Kushal Kumaran <(E-Mail Removed)>
> wrote:
>> On Mon, May 10, 2010 at 7:30 PM, (E-Mail Removed) <(E-Mail Removed)> 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
 
Reply With Quote
 
kaklis@gmail.com
Guest
Posts: n/a
 
      05-11-2010
On May 11, 5:06*am, Kushal Kumaran <(E-Mail Removed)>
wrote:
> On Mon, May 10, 2010 at 8:26 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
> > On May 10, 10:22*am, Kushal Kumaran <(E-Mail Removed)>
> > wrote:
> >> On Mon, May 10, 2010 at 7:30 PM, (E-Mail Removed) <(E-Mail Removed)> 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


Ok I got it!
Thank you!!!

A.K
 
Reply With Quote
 
kaklis@gmail.com
Guest
Posts: n/a
 
      05-11-2010
On May 11, 10:56*am, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
> On May 11, 5:06*am, Kushal Kumaran <(E-Mail Removed)>
> wrote:
>
>
>
> > On Mon, May 10, 2010 at 8:26 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
> > > On May 10, 10:22*am, Kushal Kumaran <(E-Mail Removed)>
> > > wrote:
> > >> On Mon, May 10, 2010 at 7:30 PM, (E-Mail Removed) <(E-Mail Removed)> 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

>
> Ok I got it!
> Thank you!!!
>
> A.K


Apparently the server i'm trying to connect accepts only POST
connections. So xmlrpclib is useless.
I think I need the httplib library module.

Any hints?

A.K.
 
Reply With Quote
 
Kushal Kumaran
Guest
Posts: n/a
 
      05-12-2010
On Tue, May 11, 2010 at 3:59 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
> On May 11, 10:56*am, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
>> On May 11, 5:06*am, Kushal Kumaran <(E-Mail Removed)>
>> wrote:
>>
>>
>>
>> > On Mon, May 10, 2010 at 8:26 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
>> > > On May 10, 10:22*am, Kushal Kumaran <(E-Mail Removed)>
>> > > wrote:
>> > >> On Mon, May 10, 2010 at 7:30 PM, (E-Mail Removed) <(E-Mail Removed)> 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

>>
>>
>> Ok I got it!
>> Thank you!!!
>>
>> A.K

>
> Apparently the server i'm trying to connect accepts only POST
> connections. So xmlrpclib is useless.
> I think I need the httplib library module.
>
> Any hints?
>


I don't understand. xmlrpclib sends POST requests only. Are you
getting an exception? If so, please post the entire stack trace.

If you want to send the data "by hand", use the httplib module. you
can pass your XML to the HTTPConnection.request method as the "body"
argument.

--
regards,
kushal
 
Reply With Quote
 
kaklis@gmail.com
Guest
Posts: n/a
 
      05-12-2010
On May 12, 6:13*am, Kushal Kumaran <(E-Mail Removed)>
wrote:
> On Tue, May 11, 2010 at 3:59 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
> > On May 11, 10:56*am, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
> >> On May 11, 5:06*am, Kushal Kumaran <(E-Mail Removed)>
> >> wrote:

>
> >> > On Mon, May 10, 2010 at 8:26 PM, (E-Mail Removed) <(E-Mail Removed)> wrote:
> >> > > On May 10, 10:22*am, Kushal Kumaran <kushal.kumaran+pyt...@gmail..com>
> >> > > wrote:
> >> > >> On Mon, May 10, 2010 at 7:30 PM, (E-Mail Removed) <(E-Mail Removed)> 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

>
> >> Ok I got it!
> >> Thank you!!!

>
> >> A.K

>
> > Apparently the server i'm trying to connect accepts only POST
> > connections. So xmlrpclib is useless.
> > I think I need the httplib library module.

>
> > Any hints?

>
> I don't understand. *xmlrpclib sends POST requests only. *Are you
> getting an exception? *If so, please post the entire stack trace.
>
> If you want to send the data "by hand", use the httplib module. *you
> can pass your XML to the HTTPConnection.request method as the "body"
> argument.
>
> --
> regards,
> kushal


Ok i found it. I sent the xml by hand with httplib module.
i use the last example of http://docs.python.org/library/httplib.html
and it worked.
Thank you very much for your response.

A.K.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
urllib2.Request:: http Request sending successfully, but Responsecontains in valid data. nRk Python 1 02-12-2009 12:53 AM
Why getInputStream in a http servlet request isn't getting the datasent by browser HTTP POST action? James Java 3 11-25-2005 11:17 PM
How to enter to .aspx page by http connection using http POST request farazkazmi@gmail.com Java 6 08-29-2005 02:58 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments