I am sending a request to a SOAP API and unfortunately my knowledge of SOAP is limited. The following two requests both return a response but the response differs. The not working example returns a send_fax_response only. The working returns a send_fax_response and a send_fax_result. Any ideas as to why? Could it b开发者_开发技巧e the order?
Not working
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>
Working
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>
First thing I notice is that the first line of your request is env:Envelope
in the "Not Working" example and soap:Envelope
in the "Working" example.
Aside from that, there's a couple of attributes that are also missing from this tag. They could be important, but I reckon it's the naming of that outer element which is causing the breakage.
I think your soap server expects the the body, i.e., <sendFax>
to have http://tempuri.org namespace defined within the element. If it is, changing body in the not_working soap request may also work.
<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>
i'm using Savon for Rails. My SOAP request always fails and I noticed that the working example is having soap:Envelope while my generated request has env:Envelope. How can I make my not-working SOAP request into a working SOAP request? Help please :)
精彩评论