【问题标题】:savon soap attributessavon肥皂属性
【发布时间】:2014-07-21 17:01:35
【问题描述】:

我正在尝试查询 netsuite api 的货币。以下肥皂请求适用于 SOAP UI 客户端。但是我很难尝试使用 ruby​​ 的 savon gem 版本 0.9.7 进行相同的工作。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:messages_2012_2.platform.webservices.netsuite.com" xmlns:urn1="urn:core_2012_2.platform.webservices.netsuite.com">
   <soapenv:Header>
      <urn:passport>
         <urn1:email>xxx@abc.com</urn1:email>
         <urn1:password>xxx</urn1:password>
         <urn1:account>xxx</urn1:account>
      </urn:passport>
   </soapenv:Header>
   <soapenv:Body>
      <urn:getAll>
         <urn:record recordType="currency"/>
      </urn:getAll>
   </soapenv:Body>
</soapenv:Envelope>

基本上我无法在 urn:record 元素上设置属性。以下方法不起作用:

response = client.request :urn, :get_all do
  soap.body = { "urn:record" => { :attributes! => { "recordType" => "currency" } } }
end

请指教。

【问题讨论】:

    标签: soap savon netsuite


    【解决方案1】:

    http://savonrb.com 中所述,attributes! 哈希中的键必须与 XML 标记匹配。你想写这样的东西:

    response = client.request :urn, :get_all 做 soap.body = {'urn:record'=>'', :attributes!=>{'urn:record'=>{'recordType'=>'currency'}} } 结尾

    请让我们知道这是否能为您解决问题。

    【讨论】:

    • 感谢 Steffen,它似乎已经前进了。但它现在失败了,因为我认为它期望“soapenv:”作为 Header 和 Body 标签的前缀,而不仅仅是“env:”。你知道如何让这个前缀生效吗?
    • 知道了,它的 soap.env_namespace = "soapenv" 但这并没有帮助,因为它没有发送肥皂标题。
    • 终于用soap.header = passport_header设置工作了。其中 passport_header 是 { 'urn:passport' => { 'urn:email' => NETSUITE_EMAIL, 'urn:password' => NETSUITE_PWD, 'urn:account' => NETSUITE_ACCT } }
    【解决方案2】:

    仔细检查原始肥皂请求。 :get_all 可能需要是 "getAll" 才能让 savon 从字面上理解;它可能会将其更改为GetAll

    【讨论】:

    • 默认是Savon将:get_all转换成getAll。请参阅savonrb.com 上的文档
    【解决方案3】:

    在 savon 的新版本中,您可以将 :attributes 放置在操作标记的本地上下文中:

    @interaction_client.call(:retrieve_interaction, message: message_hash, :attributes => {  'attachmentInfo' => include_attachments.to_s  }) 
    

    在这种情况下,attachmentInfo 属性将被放置到与操作链接的主操作标记中,在此示例中,这将是ns:RetrieveInteractionRequest 标记。

    请注意语法不包含感叹号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多