HTTP Post Request

Discussion in 'Python' started by kaklis@gmail.com, May 10, 2010.

  1. Guest

    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
     
    , May 10, 2010
    #1
    1. Advertising

  2. On Mon, May 10, 2010 at 7:30 PM, <> 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
     
    Kushal Kumaran, May 10, 2010
    #2
    1. Advertising

  3. Guest

    On May 10, 10:22 am, Kushal Kumaran <>
    wrote:
    > On Mon, May 10, 2010 at 7:30 PM, <> 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.
     
    , May 10, 2010
    #3
  4. On Mon, May 10, 2010 at 8:26 PM, <> wrote:
    > On May 10, 10:22 am, Kushal Kumaran <>
    > wrote:
    >> On Mon, May 10, 2010 at 7:30 PM, <> 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
     
    Kushal Kumaran, May 11, 2010
    #4
  5. Guest

    On May 11, 5:06 am, Kushal Kumaran <>
    wrote:
    > On Mon, May 10, 2010 at 8:26 PM, <> wrote:
    > > On May 10, 10:22 am, Kushal Kumaran <>
    > > wrote:
    > >> On Mon, May 10, 2010 at 7:30 PM, <> 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
     
    , May 11, 2010
    #5
  6. Guest

    On May 11, 10:56 am, "" <> wrote:
    > On May 11, 5:06 am, Kushal Kumaran <>
    > wrote:
    >
    >
    >
    > > On Mon, May 10, 2010 at 8:26 PM, <> wrote:
    > > > On May 10, 10:22 am, Kushal Kumaran <>
    > > > wrote:
    > > >> On Mon, May 10, 2010 at 7:30 PM, <> 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.
     
    , May 11, 2010
    #6
  7. On Tue, May 11, 2010 at 3:59 PM, <> wrote:
    > On May 11, 10:56 am, "" <> wrote:
    >> On May 11, 5:06 am, Kushal Kumaran <>
    >> wrote:
    >>
    >>
    >>
    >> > On Mon, May 10, 2010 at 8:26 PM, <> wrote:
    >> > > On May 10, 10:22 am, Kushal Kumaran <>
    >> > > wrote:
    >> > >> On Mon, May 10, 2010 at 7:30 PM, <> 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
     
    Kushal Kumaran, May 12, 2010
    #7
  8. Guest

    On May 12, 6:13 am, Kushal Kumaran <>
    wrote:
    > On Tue, May 11, 2010 at 3:59 PM, <> wrote:
    > > On May 11, 10:56 am, "" <> wrote:
    > >> On May 11, 5:06 am, Kushal Kumaran <>
    > >> wrote:

    >
    > >> > On Mon, May 10, 2010 at 8:26 PM, <> wrote:
    > >> > > On May 10, 10:22 am, Kushal Kumaran <kushal.kumaran+pyt...@gmail..com>
    > >> > > wrote:
    > >> > >> On Mon, May 10, 2010 at 7:30 PM, <> 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.
     
    , May 12, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. basic
    Replies:
    3
    Views:
    6,151
    Wendy S
    Jan 27, 2005
  2. Replies:
    6
    Views:
    5,573
    Tor Iver Wilhelmsen
    Aug 29, 2005
  3. James
    Replies:
    3
    Views:
    16,479
    Roedy Green
    Nov 25, 2005
  4. ColinK
    Replies:
    0
    Views:
    562
    ColinK
    Jul 15, 2007
  5. James Appleby
    Replies:
    1
    Views:
    2,545
    Donkey Hot
    Feb 6, 2008
Loading...

Share This Page