首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ruby的soap4r没有提供命名空间?

Ruby的soap4r没有提供命名空间?
EN

Stack Overflow用户
提问于 2012-06-10 02:01:32
回答 1查看 340关注 0票数 0

我试图使用soap4r (来自https://github.com/mumboe/soap4r)为一个名为SysAid的产品编写SOAP客户端。

我有一个Java中SOAP客户机的工作示例,对于大多数方法,我的Ruby客户机也能工作。Java客户端在使用Ruby版本确定错误时非常有用。

当我使用特定的呼叫时,我收到了一个错误:

代码语言:javascript
复制
SOAP::FaultError: prefix xs is not bound to a namespace

下面是soap4r发送的消息,它生成了这个错误:

代码语言:javascript
复制
<?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发送给相同方法的内容,服务器不会抱怨这个方法:

代码语言:javascript
复制
<?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将所需的属性添加到键标记中?

EN

回答 1

Stack Overflow用户

发布于 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“。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10965884

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档