2

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 `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?

crayfish
  • 147
  • 1
  • 3
  • 10

5 Answers5

2

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.

Bob Briski
  • 590
  • 4
  • 13
2

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.

csalzman
  • 61
  • 4
1

You probably just need to send in your API credentials:

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

before making requests.

trptcolin
  • 2,320
  • 13
  • 16
0

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']
  }
})
Max
  • 21,123
  • 5
  • 49
  • 71
0

Is should be client.wsdl.soap_actions

Ura
  • 2,173
  • 3
  • 24
  • 41