我在为下面的内容生成soap文档时遇到问题。这也是我第一次用肥皂。经过一些研究和建议,萨文似乎是一条路要走。

require 'savon'

client = Savon::Client.new("https://webservice.exacttarget.com/etframework.wsdl")

client.wsdl_soap_actions
# [:create, :retrieve, :update, :delete, :query, :describe, :execute, :perform, :configure, :schedule, :version_info, :extract, :get_system_status]

response = client.retrieve do |soap|
  soap.input = "Retrieve"
  soap.action = "Retrieve"
end

我在丢失的安全头上发现以下错误。
Savon::SOAPFault: (q0:Security) Security requirements are not satisfied because the security header is not present in the incoming message.
 from /home/kj/.rvm/gems/ruby-1.9.2-p0/gems/savon-0.7.9/lib/savon/response.rb:141:in `handle_soap_fault'
 from /home/kj/.rvm/gems/ruby-1.9.2-p0/gems/savon-0.7.9/lib/savon/response.rb:81:in `initialize'
 from /home/kj/.rvm/gems/ruby-1.9.2-p0/gems/savon-0.7.9/lib/savon/client.rb:95:in `new'
 from /home/kj/.rvm/gems/ruby-1.9.2-p0/gems/savon-0.7.9/lib/savon/client.rb:95:in `method_missing'
 from (irb):8
 from /home/kj/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'

我已经在这里粘贴了完整的响应。http://pastie.org/1349438
有人能帮我解决这个问题吗?

最佳答案

exacttarget的soap实现相当弱。你根本无法使用savon的soap_操作。您需要将大部分信封手工编码为散列,并在头中手动设置soapaction。不过,savon确实把大部分猜测从信封头中去掉了。下面是提取筛选器订阅服务器列表的示例:

client = Savon::Client.new do | wsdl, http, wsse |
  wsdl.document = 'https://webservice.s4.exacttarget.com/etframework.wsdl'
  wsse.credentials "username", "password"
end

res = client.request :ins0, 'RetrieveRequestMsg' do
  soap.body = {
    'RetrieveRequest' =>
    {
      'ObjectType' => 'Subscriber',
      'Properties' => ['ID', 'SubscriberKey'],
      :attributes! =>
      {
        'ins0:Filter' => {"xsi:type" => "ins0:SimpleFilterPart"}
      },
      'Filter'     =>
      {
        'Property'   => 'SubscriberKey',
        'SimpleOperator' => 'like',
        'Value'          => 'string_to_filter_by'
      }
    }
  }
  http.headers['SOAPAction'] = 'Retrieve'
end

您可能还需要根据您的帐户类型从wsdl url中删除“s4”。

关于ruby - 将savon与精确目标的网络服务一起使用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4359367/

10-09 08:27