Ruby的soap4r没有提供名称空间?

时间:2012-06-10 02:01:32

标签: ruby web-services wsdl xml-namespaces soap4r

我正在尝试使用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将此必需属性添加到密钥标记?

1 个答案:

答案 0 :(得分:0)

我认为命名空间“xmlns:xsd =”http://www.w3.org/2001/XMLSchema“已在”env:Envelope“中定义,问题是为什么在body soap4r中使用”xs: string“而不是”xsd:string“。