Re: Sending XML to a WEB Service and Getting Response Back

Discussion in 'Python' started by Hidura, Dec 20, 2010.

  1. Hidura

    Hidura Guest

    I recommend you use the urllib.request in the library of python says
    everything that you want to know.

    2010/12/20, Anurag Chourasia <>:
    > Dear Python Mates,
    >
    > I have a requirement to send a XML Data to a WEB Service whose URL is of the
    > form http://joule:8041/DteEnLinea/ws/EnvioGuia.jws
    >
    > I also have to read back the response returned as a result of sending this
    > data to this WebService.
    >
    > This web service implements the following operations:
    > sendNCR
    >
    > This web service has no callbacks.
    >
    > I have pasted the complete WSDL for this WEB Service below my email.
    >
    > I would appreciate if someone could guide me with sample code using a Python
    > Library suitable to fulfill this requirement of mine.
    >
    > Regards,
    > Anurag
    >
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <wsdl:definitions xmlns:conv="
    > http://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="
    > http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="
    > http://schemas.xmlsoap.org/wsdl/http/" xmlns:jms="
    > http://www.openuri.org/2002/04/wsdl/jms/" xmlns:mime="
    > http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="
    > http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.openuri.org/"
    > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="
    > http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="
    > http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.openuri.org/">
    > <wsdl:types>
    > <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
    > elementFormDefault="qualified" targetNamespace="http://www.openuri.org/">
    > <s:element name="sendNCR">
    > <s:complexType>
    > <s:sequence>
    > <s:element name="xml" type="s:string" minOccurs="0"/>
    > </s:sequence>
    > </s:complexType>
    > </s:element>
    > <s:element name="sendNCRResponse">
    > <s:complexType>
    > <s:sequence>
    > <s:element name="sendNCRResult" type="s:int"/>
    > </s:sequence>
    > </s:complexType>
    > </s:element>
    > <s:element name="int" type="s:int"/>
    > </s:schema>
    >
    > </wsdl:types>
    > <wsdl:message name="sendNCRSoapIn">
    > <wsdl:part name="parameters" element="s0:sendNCR"/>
    > </wsdl:message>
    > <wsdl:message name="sendNCRSoapOut">
    > <wsdl:part name="parameters" element="s0:sendNCRResponse"/>
    > </wsdl:message>
    > <wsdl:message name="sendNCRHttpGetIn">
    > <wsdl:part name="xml" type="s:string"/>
    > </wsdl:message>
    > <wsdl:message name="sendNCRHttpGetOut">
    > <wsdl:part name="Body" element="s0:int"/>
    > </wsdl:message>
    > <wsdl:message name="sendNCRHttpPostIn">
    > <wsdl:part name="xml" type="s:string"/>
    > </wsdl:message>
    > <wsdl:message name="sendNCRHttpPostOut">
    > <wsdl:part name="Body" element="s0:int"/>
    > </wsdl:message>
    > <wsdl:portType name="EnvioGuiaSoap">
    > <wsdl:eek:peration name="sendNCR">
    > <wsdl:input message="s0:sendNCRSoapIn"/>
    > <wsdl:eek:utput message="s0:sendNCRSoapOut"/>
    > </wsdl:eek:peration>
    > </wsdl:portType>
    > <wsdl:portType name="EnvioGuiaHttpGet">
    > <wsdl:eek:peration name="sendNCR">
    > <wsdl:input message="s0:sendNCRHttpGetIn"/>
    > <wsdl:eek:utput message="s0:sendNCRHttpGetOut"/>
    > </wsdl:eek:peration>
    > </wsdl:portType>
    > <wsdl:portType name="EnvioGuiaHttpPost">
    > <wsdl:eek:peration name="sendNCR">
    > <wsdl:input message="s0:sendNCRHttpPostIn"/>
    > <wsdl:eek:utput message="s0:sendNCRHttpPostOut"/>
    > </wsdl:eek:peration>
    > </wsdl:portType>
    > <wsdl:binding name="EnvioGuiaSoap" type="s0:EnvioGuiaSoap">
    > <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
    > style="document"/>
    > <wsdl:eek:peration name="sendNCR">
    > <soap:eek:peration soapAction="http://www.openuri.org/sendNCR"
    > style="document"/>
    > <wsdl:input>
    > <soap:body use="literal"/>
    > </wsdl:input>
    > <wsdl:eek:utput>
    > <soap:body use="literal"/>
    > </wsdl:eek:utput>
    > </wsdl:eek:peration>
    > </wsdl:binding>
    > <wsdl:binding name="EnvioGuiaHttpGet" type="s0:EnvioGuiaHttpGet">
    > <http:binding verb="GET"/>
    > <wsdl:eek:peration name="sendNCR">
    > <http:eek:peration location="/sendNCR"/>
    > <wsdl:input>
    > <http:urlEncoded/>
    > </wsdl:input>
    > <wsdl:eek:utput>
    > <mime:mimeXml part="Body"/>
    > </wsdl:eek:utput>
    > </wsdl:eek:peration>
    > </wsdl:binding>
    > <wsdl:binding name="EnvioGuiaHttpPost" type="s0:EnvioGuiaHttpPost">
    > <http:binding verb="POST"/>
    > <wsdl:eek:peration name="sendNCR">
    > <http:eek:peration location="/sendNCR"/>
    > <wsdl:input>
    > <mime:content type="application/x-www-form-urlencoded"/>
    > </wsdl:input>
    > <wsdl:eek:utput>
    > <mime:mimeXml part="Body"/>
    > </wsdl:eek:utput>
    > </wsdl:eek:peration>
    > </wsdl:binding>
    > <wsdl:service name="EnvioGuia">
    > <wsdl:port name="EnvioGuiaSoap" binding="s0:EnvioGuiaSoap">
    > <soap:address location="http://joule:8041/DteEnLinea/ws/EnvioGuia..jws
    > "/>
    > </wsdl:port>
    > <wsdl:port name="EnvioGuiaHttpGet" binding="s0:EnvioGuiaHttpGet">
    > <http:address location="http://joule:8041/DteEnLinea/ws/EnvioGuia..jws
    > "/>
    > </wsdl:port>
    > <wsdl:port name="EnvioGuiaHttpPost" binding="s0:EnvioGuiaHttpPost">
    > <http:address location="http://joule:8041/DteEnLinea/ws/EnvioGuia..jws
    > "/>
    > </wsdl:port>
    > </wsdl:service>
    > </wsdl:definitions>
    >


    --
    Enviado desde mi dispositivo móvil

    Diego I. Hidalgo D.
     
    Hidura, Dec 20, 2010
    #1
    1. Advertising

  2. Hidura

    John Nagle Guest

    On 12/20/2010 12:14 PM, Hidura wrote:
    > I recommend you use the urllib.request in the library of python says
    > everything that you want to know.
    >
    > 2010/12/20, Anurag Chourasia<>:
    >> Dear Python Mates,
    >>
    >> I have a requirement to send a XML Data to a WEB Service whose URL is of the
    >> form http://joule:8041/DteEnLinea/ws/EnvioGuia.jws
    >>
    >> I also have to read back the response returned as a result of sending this
    >> data to this WebService.
    >>
    >> This web service implements the following operations:
    >> sendNCR
    >>
    >> This web service has no callbacks.
    >>
    >> I have pasted the complete WSDL for this WEB Service below my email.
    >>
    >> I would appreciate if someone could guide me with sample code using a Python
    >> Library suitable to fulfill this requirement of mine.
    >>
    >> Regards,
    >> Anurag


    If you're writing the client side, the service talks SOAP, and
    you have a WSDL file, use the "suds" module.

    SOAPpy is way out of date. The last update on SourceForge was in
    2001.

    John Nagle
     
    John Nagle, Dec 21, 2010
    #2
    1. Advertising

  3. Hidura

    Ian Kelly Guest

    On 12/20/2010 11:34 PM, John Nagle wrote:
    > SOAPpy is way out of date. The last update on SourceForge was in
    > 2001.


    2007, actually: http://sourceforge.net/projects/pywebsvcs/files/

    And there is repository activity within the past 9 months. Still, point
    taken.
     
    Ian Kelly, Dec 21, 2010
    #3
  4. Hidura

    John Nagle Guest

    On 12/20/2010 11:45 PM, Ian Kelly wrote:
    > On 12/20/2010 11:34 PM, John Nagle wrote:
    >> SOAPpy is way out of date. The last update on SourceForge was in
    >> 2001.

    >
    > 2007, actually: http://sourceforge.net/projects/pywebsvcs/files/
    >
    > And there is repository activity within the past 9 months. Still, point
    > taken.


    The original SOAPpy was at

    http://sourceforge.net/projects/soapy/files/

    but was apparently abandoned in 2001. Someone else picked
    it up and moved it to

    http://sourceforge.net/projects/pywebsvcs/files/SOAP.py/

    where it was last updated in 2005. ZSI was last updated in
    2007. Users are still submitting bug reports, but nobody
    is answering. Somebody posted "Who maintains the pywebsvcs webpage?"
    in February 2009, but no one answered them.

    There's also "Python SOAP"

    http://sourceforge.net/projects/pythonsoap/

    abandoned in 2005.

    The "suds" module

    http://sourceforge.net/projects/python-suds/

    was last updated in March, 2010. That version
    will work with Python 2.6, and probably 2.7.
    There's very little project activity, but at
    least it's reasonably current.

    John Nagle
     
    John Nagle, Dec 21, 2010
    #4
  5. Thanks for the response all.

    I tried exploring suds (which seems to be the current) and i hit
    problems right away. I will now try urllib or httplib.

    I have asked for help in the suds forum. Hope somebody replies.

    When i try to create a client, the error is as follows.

    >>> from suds.client import Client
    >>> url = 'http://10.251.4.33:8041/DteEnLinea/ws/EnvioGuia.jws'
    >>> client = Client(url)


    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
    File "suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
    File "suds/wsdl.py", line 136, in __init__
    d = reader.open(url)
    File "suds/reader.py", line 79, in open
    d = self.download(url)
    File "suds/reader.py", line 101, in download
    return sax.parse(string=content)
    File "suds/sax/parser.py", line 136, in parse
    sax.parse(source)
    File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
    File "/usr/local/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
    File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 211, in feed
    self._err_handler.fatalError(exc)
    File "/usr/local/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
    raise exception
    xml.sax._exceptions.SAXParseException: <unknown>:1:62: syntax error
    >>> [3] + Stopped (SIGTSTP) python


    This seems to be a old problem passing versions.

    Regards,
    Anurag

    On Wed, Dec 22, 2010 at 12:40 AM, John Nagle <> wrote:
    > On 12/20/2010 11:45 PM, Ian Kelly wrote:
    >>
    >> On 12/20/2010 11:34 PM, John Nagle wrote:
    >>>
    >>> SOAPpy is way out of date. The last update on SourceForge was in
    >>> 2001.

    >>
    >> 2007, actually: http://sourceforge.net/projects/pywebsvcs/files/
    >>
    >> And there is repository activity within the past 9 months. Still, point
    >> taken.

    >
    >   The original SOAPpy was at
    >
    >        http://sourceforge.net/projects/soapy/files/
    >
    > but was apparently abandoned in 2001. Someone else picked
    > it up and moved it to
    >
    >        http://sourceforge.net/projects/pywebsvcs/files/SOAP.py/
    >
    > where it was last updated in 2005.  ZSI was last updated in
    > 2007.  Users are still submitting bug reports, but nobody
    > is answering.  Somebody posted "Who maintains the pywebsvcs webpage?"
    > in February 2009, but no one answered them.
    >
    >    There's also "Python SOAP"
    >
    > http://sourceforge.net/projects/pythonsoap/
    >
    > abandoned in 2005.
    >
    >    The "suds" module
    >
    > http://sourceforge.net/projects/python-suds/
    >
    > was last updated in March, 2010.  That version
    > will work with Python 2.6, and probably 2.7.
    > There's very little project activity, but at
    > least it's reasonably current.
    >
    >                                John Nagle
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
     
    Anurag Chourasia, Dec 21, 2010
    #5
  6. Hidura

    Ian Kelly Guest

    Ian Kelly, Dec 21, 2010
    #6
  7. Hidura

    John Nagle Guest

    On 12/21/2010 11:26 AM, Anurag Chourasia wrote:
    > Thanks for the response all.
    >
    > I tried exploring suds (which seems to be the current) and i hit
    > problems right away. I will now try urllib or httplib.
    >
    > I have asked for help in the suds forum. Hope somebody replies.
    >
    > When i try to create a client, the error is as follows.
    >
    >>>> from suds.client import Client
    >>>> url = 'http://10.251.4.33:8041/DteEnLinea/ws/EnvioGuia.jws'
    >>>> client = Client(url)

    >
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in<module>
    > File "suds/client.py", line 112, in __init__
    > self.wsdl = reader.open(url)
    > File "suds/reader.py", line 152, in open
    > d = self.fn(url, self.options)
    > File "suds/wsdl.py", line 136, in __init__
    > d = reader.open(url)
    > File "suds/reader.py", line 79, in open
    > d = self.download(url)
    > File "suds/reader.py", line 101, in download
    > return sax.parse(string=content)
    > File "suds/sax/parser.py", line 136, in parse
    > sax.parse(source)
    > File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
    > xmlreader.IncrementalParser.parse(self, source)
    > File "/usr/local/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    > self.feed(buffer)
    > File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 211, in feed
    > self._err_handler.fatalError(exc)
    > File "/usr/local/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
    > raise exception
    > xml.sax._exceptions.SAXParseException:<unknown>:1:62: syntax error
    >>>> [3] + Stopped (SIGTSTP) python

    >
    > This seems to be a old problem passing versions.
    >
    > Regards,
    > Anurag


    Try posting a URL that isn't on network 10. That's some local
    network at your end.

    John Nagle
     
    John Nagle, Dec 22, 2010
    #7
    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. Replies:
    2
    Views:
    685
  2. Saaji
    Replies:
    1
    Views:
    3,305
    Darryl L. Pierce
    Mar 22, 2006
  3. Digital Puer
    Replies:
    1
    Views:
    885
    Dag Sunde
    Jun 1, 2006
  4. Amol Kasbekar

    Securing response send back by Web Service

    Amol Kasbekar, Sep 17, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    105
    Amol Kasbekar
    Sep 17, 2004
  5. Adam Funk
    Replies:
    9
    Views:
    401
    Adam Funk
    Jul 31, 2006
Loading...

Share This Page