我试图使用soap4r (来自https://github.com/mumboe/soap4r)为一个名为SysAid的产品编写SOAP客户端。
我有一个Java中SOAP客户机的工作示例,对于大多数方法,我的Ruby客户机也能工作。Java客户端在使用Ruby版本确定错误时非常有用。
当我使用特定的呼叫时,我收到了一个错误:
SOAP::FaultError: prefix xs is not bound to a namespace下面是soap4r发送的消息,它生成了这个错误:
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<n1:save xmlns:n1="http://api.ilient.com/">
<sessionId>1339292997261</sessionId>
<apiSysObj xsi:type="n1:apiServiceRequest">
<customDateFields></customDateFields>
<customFields>
<entry>
<key xsi:type="xs:string">sr_cust_dafis_fau</key>
<value xsi:type="xs:string"></value>
</entry>
<entry>
<key xsi:type="xs:string">sr_cust_activity</key>
</entry>
</customFields>
<description>This is the description of the ticket.</description>
</apiSysObj>
</n1:save>
</env:Body>
</env:Envelope>以下是Java发送给相同方法的内容,服务器不会抱怨这个方法:
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:save xmlns:ns2="http://api.ilient.com/">
<sessionId>1339199684324</sessionId>
<apiSysObj xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:apiServiceRequest">
<customDateFields/><customFields>
<entry>
<key xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">sr_cust_dafis_fau</key>
<value xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string"></value>
</entry>
<entry>
<key xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">sr_cust_activity</key>
</entry>
</customFields>
<description>This is the description of the ticket.</description>
</apiSysObj>
</ns2:save>
</S:Body>
</S:Envelope>如您所见,错误来自customFields标记。soap4r遗漏了键标记上的xmlns:xs属性,而Java则将其放入其中。
据我所知,soap4r不会在任何其他方法调用上发生类似的关键错误。
如何让soap4r将所需的属性添加到键标记中?
发布于 2012-06-29 03:39:28
我认为名称空间“xmlns:xsd=”http://www.w3.org/2001/XMLSchema是在“env:http://www.w3.org/2001/XMLSchema”中定义的,问题是为什么在主体soap4r中使用“xs:http://www.w3.org/2001/XMLSchema”而不是"xsd:string“。
https://stackoverflow.com/questions/10965884
复制相似问题