Web Services examples using "raw" xml?

John Gordon gordon at panix.com
Tue Aug 25 12:19:33 EDT 2009


In <4a936e84$0$31337$9b4e6d93 at newsspool4.arcor-online.net> Stefan Behnel <stefan_ml at behnel.de> writes:

> > I tried WSDL.Proxy() from the SOAPpy package and eventually end up
> > with this error:
> > 
> > xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 6

> Is that while parsing the WSDL file? Have you tried pushing it through an
> XML parser yourself (or opening it with an XML editor) to see if it really
> is XML?

The 'invalid token' error happens if the argument to WSDL.Proxy() is a
string containing a URL beginning with https.  (It doesn't happen with a
http URL, but I'm stuck with https.)

As a next step, I grabbed the content from the https url in a browser,
saved it to a file, inserted it into the python code as a large string,
and passed that string to WSDL.Proxy().

That produced a KeyError 'targetNamespace' from this snippet of XML:

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="messages.xsd"/>
  </xs:schema>

I looked at the code and it apparently requires that the parent tag of
<xs:import> have a targetNamespace attribute.  So I made one up and added
it, like so:

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="xyz">

I have no idea if this was the right thing to do, but it did let me advance
to the next error:

  Traceback (most recent call last):
  File "soappytest.py", line 1020, in ?
    server = jrgWSDL.Proxy(wsdlFile)
  File "/home/gordonj/wsdl/jrgSOAPpy/jrgWSDL.py", line 75, in __init__
    service = self.wsdl.services[0]
  File "/home/gordonj/wsdl/jrgwstools/Utility.py", line 631, in __getitem__
    return self.list[key]
IndexError: list index out of range

After poking around in the code a bit more, I think that self.wsdl.services
is supposed to be a collection of all the services offered by the wsdl, but
it's actually empty, which is why it throws an error when it tries to
access the first element.

So that's where I'm stuck at the moment.  I have no idea why
self.wsdl.services isn't getting populated correctly -- or even if that's
the real problem!

Any suggestions?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list