我在制作以下的肥皂文件时遇到问题。这也是我第一次使用肥皂。经过一些研究和推荐,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
任何善良的灵魂能帮助我解决这个问题吗?
答案 0 :(得分: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网址中删除“s4”,具体取决于您的帐户类型。
答案 1 :(得分:2)
答案 2 :(得分:1)
您可能只需要发送您的API凭据:
Savon::WSSE.username = "USERNAME_HERE"
Savon::WSSE.password = "PASSWORD_HERE"
在提出请求之前。
答案 3 :(得分:0)
应该是client.wsdl.soap_actions
答案 4 :(得分: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']
}
})