为没有WSDL的SOAP端点构造请求数据

问题描述 投票:0回答:1

端点URL看起来像这样(不是实际的URL)https://webservices.abcde.com/ThirdParty/PostData.V55.ashx/ProcessRequest

它没有WSDL,并且在文档中有一个示例请求XML。

非常大。我在下面添加了前几行。

<MESSAGE xmlns:agentnet="http://services.abcde.com/entity/agentnet/v2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.mismo.org/residential/2009/schemas/v32">
<ABOUT_VERSIONS>
  <ABOUT_VERSION>
    <AboutVersionIdentifier>ClientSystem</AboutVersionIdentifier>
    <DataVersionIdentifier>1.0</DataVersionIdentifier>
    <DataVersionName>ASDFSFD</DataVersionName>
  </ABOUT_VERSION>
</ABOUT_VERSIONS>
<DEAL_SETS>
  <DEAL_SET>
        <DEALS>
          <DEAL>
            <PARTIES/>
            <SERVICES>
              <SERVICE>
                <SERVICE_PRODUCT>
                  <SERVICE_PRODUCT_REQUEST>
                    <EXTENSION>
                      <OTHER>
                        <agentnet:AGENTNET_PRODUCT_REQUEST>
<agentnet:AgentNetServiceType>GET_DATA</agentnet:AgentNetServiceType>
                          <agentnet:AGENTNET_GET_DATA>
                            <agentnet:GetRequestType>ACCOUNTS</agentnet:GetRequestType>
                          </agentnet:AGENTNET_GET_DATA>
                        </agentnet:AGENTNET_PRODUCT_REQUEST>
...
...
...
...
... (the XML is huge)

[与其他端点一起,我能够使用savon之类的SOAP库通过小的Ruby Hash(dictionary)来生成XML有效负载。

我认为这是可能的,因为那是WSDL?

是否有可能通过仅传递一些基本数据(例如,示例中的GET_DATAACCOUNTS)以相同的方式生成有效载荷,或者我应该手动构造XML有效载荷字符串(也许使用某些XML库)?

我真的想避免手动构造XML有效负载,因为代码将不可读,并且通常很难使用。有办法避免吗?

soap wsdl savon
1个回答
0
投票

您可以在不使用WSDL的情况下最终创建Savon客户端。我个人更喜欢这种方式,因为我认为它的性能更高。

[在创建客户时必须定义endpointnamespace,例如这个虚构的示例:

require 'savon'

c = Savon.client(endpoint: "http://www.example.com",
                 namespace: "urn:ns.example.com",
                 log: true,
                 log_level: :debug,
                 pretty_print_xml: true)

r = c.call(:call,
           :message => { 
                  :InquiryParam => [ 
                         {"crmParam" => 123,
                        :attributes! => { "crmParam" => { "name" => "AccountNumber" }}},
                         {"crmParam" => 456,
                        :attributes! => { "crmParam" => { "name" => "history" }}}
                        ]
                  }
          )
© www.soinside.com 2019 - 2024. All rights reserved.