Posting XML to web service using SOAP Savon gem in ruby on rails -
i'm working ruby , savon 2. have been given following soap example:
post /webapi/services/b2bapi.asmx http/1.1 host: api.nationsphotolab.com content-type: text/xml; charset=utf-8 content-length: length soapaction: "https://api.nationsphotolab.com/addneworder" <?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> <addneworder xmlns="http://api.nationsphotolab.com/"> <orderxml>string</orderxml> <passport> <source>string</source> <hash>string</hash> </passport> </addneworder> </soap:body> </soap:envelope>
i have tried bunch of different methods of creating xml, first using xmlmarkup builder, , building hash , passing savon client call.
the error i've been getting: savon::soapfault ((soap:server) server unable process request. ---> object reference not set instance of object.):
here's request:
client = savon.client(wsdl: "http://api.nationsphotolab.com/webapi/services/b2bapi.asmx?wsdl") response = client.call(:add_new_order, message: data)
with data being xml created using xmlmarkup builder. attached screenshot of data.
please let me know if can provide anymore information
thank you!
from description looks api expecting orderxml
element string. think problem put xml orderxml
element, when api expecting contain string.
escaping contents of orderxml
element , sending string should solve problem.
the code below shows 1 way of escaping xml strings: order_xml_string.encode(xml: :text)
Comments
Post a Comment