0

I dug as deep as I could but could not find a solution to my problem:

I want to send SOAP requests to ExactTarget API. I am trying to use Savon, but the requests it creates are different from those that worked with ExactTarget's API (I used Java previously) and in the end I get an error when running the Ruby script.

Below is the body of a working request that I am to create in Ruby:

<S:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
            <ObjectType>BounceEvent</ObjectType>
            <Properties>SendID</Properties>
            <Properties>SubscriberKey</Properties>
            <Properties>EventDate</Properties>
            <Properties>SMTPCode</Properties>
            <Properties>BounceCategory</Properties>
            <Properties>SMTPReason</Properties>
            <Properties>BounceType</Properties>
            <Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SimpleFilterPart">
                <Property>SendID</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>421939</Value>
            </Filter>
        </RetrieveRequest>
</RetrieveRequestMsg>
</S:Body>

Now here is the code I created in Ruby:

client = Savon.client do
  wsdl 'https://webservice.s4.exacttarget.com/etframework.wsdl'  
  wsse_auth("user", "pass")
end

builder = Builder::XmlMarkup.new
builder.instruct!(:xml, encoding: "UTF-8")

#builder.RetrieveRequestMsg('xmlns'=>'http://exacttarget.com/wsdl/partnerAPI') do
  builder.RetrieveRequest do
    builder.ObjectType "BounceEvent"
    builder.Properties "SendID"
    builder.Properties "SubscriberKey"
  end
#end

theBody = builder.target!
theBody.slice! '<?xml version="1.0" encoding="UTF-8"?>'

client.call(:retrieve, message: theBody)

..and here is the resulting request body:

<env:Body>
    <tns:RetrieveRequestMsg>
        <RetrieveRequest>
            <ObjectType>BounceEvent</ObjectType>
            <Properties>SendID</Properties>
            <Properties>SubscriberKey</Properties>
        </RetrieveRequest></tns:RetrieveRequestMsg>
    </env:Body>    

...and here is the resulting error I get:

<soap:Body>
    <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <OverallStatus>Error</OverallStatus>
        <RequestID>5ce5cfae-85b4-4e76-b9dd-299e9a9ca871</RequestID>
    </RetrieveResponseMsg>
</soap:Body>

Any help is greatly appreciated!

Daniil Shevelev
  • 11,739
  • 12
  • 50
  • 73
  • My standard question: Have you tried it in SoapUI? Then build the Soap request with Savon. Savon uses a slightly different way to build a syntactically correct request than SoapUI or Java. Why do you use builder? Is a Savon message not enough? – Steffen Roller Oct 30 '13 at 19:59

1 Answers1

0

Rather than using Builder, try using Savons call method for generating a SOAP request.

ruby response = client.call(:authenticate, message: { username: "luke", password: "secret" })

You have the wsdl, so you should be able to determine the method name and arguments. Calling .operations on the client will list all of the available operations that you can generate.

Stuart
  • 644
  • 1
  • 6
  • 13