python soap client 使用 suds 错误: suds.TypeNotFound: Type not found


正在学习python,使用suds用soap client遇到问题,代码如下,不是所有WebServices都出错,有些是可以的。注释中的url即使可以成功的。

#! /usr/bin/env python
# -*- coding: utf-8 -*-
from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import
url = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl"
#url = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"
imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w    3.org/2001/XMLSchema.xsd')
imp.filter.add('http://webservice.webxml.com.cn/WebServices/')
d = ImportDoctor(imp)
client = Client(url, doctor=d)
print client

错误信息

Traceback (most recent call last):
  File "weather.py", line 14, in <module>
    client = Client(url, doctor=d)
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/wsdl.py", line 159, in __init__
    self.build_schema()
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/wsdl.py", line 220, in build_schema
    self.schema = container.load(self.options)
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/xsd/schema.py", line 95, in load
    child.dereference()
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/xsd/schema.py", line 323, in dereference
    midx, deps = x.dependencies()
  File "/usr/local/lib/python2.7/dist-packages/suds-0.4-py2.7.egg/suds/xsd/sxbasic.py", line 422, in dependencies
    raise TypeNotFound(self.ref)
suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'

貌似是wsdl中有错误,有什么办法?

python soap

雾雨.魔里沙 11 years ago

Your Answer