开发者

using savon with exacttarget's web service

i am having problems forming my soap document for the following. this is also my first time using soap. after some research and recommendations, savon seems the way to go.

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

I got the following error on a security header that is missing.

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开发者_Python百科 `method_missing'
 from (irb):8
 from /home/kj/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'

I've pasted the full response here. http://pastie.org/1349438

Could any kind soul help me out with this?


ExactTarget's SOAP implementation is pretty weak. You won't be able to use Savon's soap_actions at all. You'll need to handcode most of the envelope as a hash and manually set the SOAPAction in the header. Savon does take most of the guesswork out of the envelope header though. Here's an example for pulling a list of filter subscribers:

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

You also may need to remove the "s4" from the wsdl url depending on your account type.


Check out this gem:

https://github.com/daws/exact_target_sdk

Ran across it a few days ago and it's made life much easier.


You probably just need to send in your API credentials:

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

before making requests.


Is should be client.wsdl.soap_actions


I found Bob Briski's answer helpful, but I believe Savon has been updated since his answer. Here's a small example based on the latest documentation:

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']
  }
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜