SOAP suds 和可怕的模式 Type Not Found 错误
我正在使用最新版本的 suds (https://fedorahosted.org/suds/)第一次,我在第一步就停滞了。
suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'
现在,我知道这在泡沫世界中已经被广泛覆盖(https://fedorahosted. org/suds/wiki/TipsAndTricks#Schema-TypeNotFound 和 Python/Suds:未找到类型:'xs:complexType')但这似乎略有不同,因为 (a) 架构应该在版本 0.3.4 之后自动绑定,并且 (b) 即使显式使用解决方法,它仍然不会'不工作。
from suds.client import Client
from suds.xsd.sxbasic import Import
url = 'file:wsdl.wsdl'
Import.bind('http://schemas.xmlsoap.org/soap/encoding/')
client = Client(url, cache = None)
使用 wsdl:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://ws.client.com/Members.asmx"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://ws.client.com/Members.asmx"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://ws.client.com/Members.asmx">
<s:element name="GetCategoriesResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCategoriesResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
</wsdl:definitions>
会产生上述异常。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在这个问题上敲了一段时间的头。我最终使用以下语法解决了这个问题:
重要的是,从 url 开始。在浏览器中打开该文件,它将为您提供 wsdl 定义。确保您在此处输入了正确的 URL,并且确实打开了 XML 文件。另请注意 url 末尾的 ?wsdl。
其次,
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
将导入标准 SOAP 架构。第三,。
imp.filter.add('http:somedomain.com/A')
将添加您的特定命名空间。您可以通过打开上面在url=
中定义的 url 并查找还要注意 url 中的 http 与 https。
I was banging my head for a while on this one. I finally resolved the issue by using the following syntax:
Importantly, start with the url. Open that file in your browser and it will provide you with the wsdl definitions. Make sure you have the right url entered here and that an XML file actually opens. Also mind the ?wsdl at the end of the url.
Second,
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
will import the standard SOAP schema.Third,
imp.filter.add('http:somedomain.com/A')
will add your specific namespace. You can find this namespace location by opening the url you defined above inurl=
and looking for the section<wsdl:import namespace="http://somedomain.com/A"
.Also be mindful of http vs https in your urls.
我们成功了,我希望你也能成功,尽管这有点奇怪。也许明确的位置或过滤器会有所帮助。例如:
We got it working and I hope you did as well, even though it is a bit quirky. Perhaps an explicit location or filter will help. E.g.:
对于那些仍然被这个问题困扰的人。此链接 https://bitbucket.org/jurko/suds/issue/20/typenotfound -schema 可能会提供有用的信息。解决方案是这样的:
For those who still is troubled by this problem. This link https://bitbucket.org/jurko/suds/issue/20/typenotfound-schema may provide useful information. The solution would be like this: