0

我尽可能深入地挖掘,但找不到解决问题的方法:

我想向 ExactTarget API 发送 SOAP 请求。我正在尝试使用 Savon,但它创建的请求与使用 ExactTarget 的 API 的请求不同(我以前使用过 Java),最后在运行 Ruby 脚本时出现错误。

下面是我要在 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>

现在这是我在 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)

..这是生成的请求正文:

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

...这是我得到的结果错误:

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

任何帮助是极大的赞赏!

4

1 回答 1

0

Builder尝试使用Savonscall方法生成 SOAP 请求,而不是使用。

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

您拥有 wsdl,因此您应该能够确定方法名称和参数。调用.operations客户端将列出您可以生成的所有可用操作。

于 2013-10-31T01:46:41.887 回答