使用转义 xml 作为属性来使用 SOAP Web 服务
我使用 suds 来使用 SOAP Web 服务,如下所示:
from suds.client import Client
url = "http://www.example.com?wsdl"
client = Client(url)
client.service.example(xml_argument)
如果我使用此 xml 调用该方法有效:
<?xml version="1.0" encoding="UTF-8"?><a><b description="Foo Bar"></b></a>
但如果我像这样添加引号(转义):
<?xml version="1.0" encoding="UTF-8"?><a><b description="Foo " Bar"></b></a>
我收到以下错误(来自 Web 服务):
与元素类型“b”关联的属性名称“Bar”必须是 后跟“=”字符。
我正在使用版本:0.4 GA 版本:R699-20100913
我是否没有以正确的方式使用 suds.client?有什么建议吗?
更新:
我已经联系了客户支持,通过电子邮件向他们发送了我的转义 XML,他们告诉我这对他们有用,所以可能是由于我这边的泡沫使用不当造成的。我将尝试使用 PySimpleSOAP。
I am using suds to consume SOAP web services like this way:
from suds.client import Client
url = "http://www.example.com?wsdl"
client = Client(url)
client.service.example(xml_argument)
If I call the method using this xml works:
<?xml version="1.0" encoding="UTF-8"?><a><b description="Foo Bar"></b></a>
But If I add a quote (escaped) like this:
<?xml version="1.0" encoding="UTF-8"?><a><b description="Foo " Bar"></b></a>
I get the following error (from the webservice):
Attribute name "Bar" associated with an element type "b" must be
followed by the ' = ' character.
I am using version: 0.4 GA build: R699-20100913
Am I not using suds.client in the proper way? any suggestions?
UPDATE:
I have already contacted customer support, emailed them my escaped XML and they told me that it works for them, so probably is caused due a bad use from suds in my side. I'll give a try with PySimpleSOAP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的主要是猜测,但您引用的错误似乎是由提供服务的计算机上的 XML 格式良好检查器生成的。
似乎在电缆的那一侧,他们收到类似以下内容:(
"
转换为"
),因此他们告诉您应该发送一些内容就像:这显然不是你想要的。
据我所知,你的 XML 格式良好(为了额外的安全性,刚刚在此处进行了测试) ,所以要么泡沫中有一个错误(这会 让我感到惊讶)或者提供服务的服务器上存在错误(可能是从 XML 实体到常规字符的“太早转换”)。
考虑到错误的严重性和包的成熟度,这 这是确凿的事实,但我仍然很高兴:)
Mine is mostly a guess, but the error you are quoting seems to be generated from the XML well-formedness checker on the machine providing the service.
It seems that on that side of the cable they are getting something like:
(
"
converted to"
) and thus they are telling you that you should instead send something like:which is clearly not what you want.
AFAIK your XML is well formed (just tested here for extra safety), so either there is a bug in suds (which would surprise me, given the magnitude of the bug and the maturity of the package) or there is a bug on the server providing the service (possibly a "too early conversion" from XML entities to regular chars).
Again: lot of speculation and few hard facts here, but I still HTH! :)