2

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

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

任何善良的灵魂可以帮助我解决这个问题吗?

4

5 回答 5

2

ExactTarget 的 SOAP 实现非常薄弱。您根本无法使用 Savon 的 soap_actions。您需要将大部分信封手动编码为散列,并在标头中手动设置 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”。

于 2012-01-25T19:02:16.890 回答
2

看看这个宝石:

https://github.com/daws/exact_target_sdk

几天前遇到它,它使生活变得更加轻松。

于 2012-02-14T15:45:23.433 回答
1

您可能只需要发送您的 API 凭据:

Savon::WSSE.username = "USERNAME_HERE"
Savon::WSSE.password = "PASSWORD_HERE"

在提出请求之前。

于 2010-12-09T05:02:58.013 回答
0

应该是client.wsdl.soap_actions

于 2011-05-09T15:43:48.280 回答
0

我发现 Bob Briski 的回答很有帮助,但我相信 Savon 在他回答后已经更新。这是一个基于最新文档的小例子:

require 'savon'

client = Savon.client(
  wsdl: 'https://webservice.s6.exacttarget.com/etframework.wsdl',
  wsse_auth: [username, password],
  log: false,
  convert_request_keys_to: :camelcase
)

response = client.call(:retrieve, message: {
  retrieve_request: {
    object_type: 'List',
    properties: ['ID', 'List.ListName', 'List.Type', 'List.Category', 'Client.ID']
  }
})
于 2014-02-27T22:09:19.023 回答