我尽可能深地挖掘但是找不到解决问题的方法:
我想将SOAP请求发送到ExactTarget API。我正在尝试使用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>
非常感谢任何帮助!
答案 0 :(得分:0)
尝试使用Builder
s Savon
方法生成SOAP请求,而不是使用call
。
ruby
response = client.call(:authenticate, message: { username: "luke", password: "secret" })
你有wsdl,所以你应该能够确定方法名称和参数。在客户端上调用.operations
将列出您可以生成的所有可用操作。