我正在向SOAP API发送请求,遗憾的是我对SOAP的了解有限。以下两个请求都返回响应,但响应不同。不工作的示例仅返回send_fax_response。该工作返回send_fax_response和send_fax_result。任何想法为什么?可能是订单吗?
SOAP request: https://faxregistration.com/SfaxWS/SfaxAPI.asmx
SOAPAction: "http://tempuri.org/sendFax", Content-Type: text/xml;charset=UTF-8, User-Agent: sfax-api gem 0.0.1
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:wsdl="http://tempuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins0="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<ins0:sendFax>
<ins0:xDoc>
<FaxRequest>
<DocMerge>false</DocMerge>
<RecipientFax>555.123.4567</RecipientFax>
<Password>test</Password>
<UserId>test</UserId>
<image>PGh0bWw+PGJvZHk+VGVzdCBGYXg8L2JvZHk+PC9odG1sPg==</image>
<DocType>html</DocType>
<RecipientName>test</RecipientName>
</FaxRequest>
</ins0:xDoc>
</ins0:sendFax>
</env:Body>
</env:Envelope>
SOAP request: https://faxregistration.com/SfaxWS/SfaxAPI.asmx
SOAPAction: "http://tempuri.org/sendFax", Content-Type: text/xml;charset=UTF-8, User-Agent: sfax-api gem 0.0.1
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<sendFax xmlns="http://tempuri.org/">
<xDoc>
<FaxRequest>
<UserId>test</UserId>
<Password>test</Password>
<RecipientName>test</RecipientName>
<RecipientFax>555.123.4567</RecipientFax>
<DocType>html</DocType>
<image>PGh0bWw+PGJvZHk+VGVzdCBGYXg8L2JvZHk+PC9odG1sPg==</image>
<DocMerge>false</DocMerge>
</FaxRequest>
</xDoc>
</sendFax>
</soap:Body>
</soap:Envelope>
答案 0 :(得分:1)
我注意到的第一件事是您的请求的第一行在“不工作”示例中为env:Envelope
,在“工作”示例中为soap:Envelope
。
除此之外,此标记还缺少一些属性。它们可能很重要,但我认为这是导致破损的外部元素的命名。
答案 1 :(得分:1)
我认为你的soap服务器期望主体,即<sendFax>
在元素中定义http://tempuri.org命名空间。如果是,则在not_working soap请求中更改正文也可能有效。
<ins0:sendFax ins0:"http://tempuri.org/">
<ins0:xDoc>
<FaxRequest>
<DocMerge>false</DocMerge>
<RecipientFax>555.123.4567</RecipientFax>
<Password>test</Password>
<UserId>test</UserId>
<image>PGh0bWw+PGJvZHk+VGVzdCBGYXg8L2JvZHk+PC9odG1sPg==</image>
<DocType>html</DocType>
<RecipientName>test</RecipientName>
</FaxRequest>
</ins0:xDoc>
</ins0:sendFax>
答案 2 :(得分:1)
我正在使用Savon for Rails。我的SOAP请求总是失败,我发现工作示例有 soap:Envelope ,而我生成的请求有 env:Envelope 。 如何将无效 SOAP请求转换为工作 SOAP请求? 请帮助:)