Когда я пытаюсь запустить определенный клиентский запрос в SoapUI, он работает. Однако, когда я пробую это в Савоне, я получаю ошибки.
Как я могу получить мой вывод Savon похожий на этот вывод в SoapUI?
Вот SoapUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:api_paynow_authentication_new>
<!--Optional:-->
<tem:psbID>8303545188</tem:psbID>
<!--Optional:-->
<tem:username>demo@paysbuy.com</tem:username>
<!--Optional:-->
<tem:secureCode>1586093a8f80cbb5003001b42f0eeb7c</tem:secureCode>
<!--Optional:-->
<tem:inv>2009060101</tem:inv>
<!--Optional:-->
<tem:itm>PAYSBUY Test Product</tem:itm>
<!--Optional:-->
<tem:amt>1</tem:amt>
<!--Optional:-->
<tem:paypal_amt>1</tem:paypal_amt>
<!--Optional:-->
<tem:curr_type>TH</tem:curr_type>
<!--Optional:-->
<tem:com>FbRy1+sLKnl4JpuwQ6D+sg==</tem:com>
<!--Optional:-->
<tem:method>1</tem:method>
<!--Optional:-->
<tem:language>T</tem:language>
<!--Optional:-->
<tem:resp_front_url>https://www.paysbuy.com/receiveresponse/Result.aspx</tem:resp_front_url>
<!--Optional:-->
<tem:resp_back_url>https://www.paysbuy.com/receiveresponse/ResultReg.aspx</tem:resp_back_url>
<!--Optional:-->
<tem:opt_fix_redirect>?</tem:opt_fix_redirect>
<!--Optional:-->
<tem:opt_fix_method>?</tem:opt_fix_method>
<!--Optional:-->
<tem:opt_name>?</tem:opt_name>
<!--Optional:-->
<tem:opt_email>?</tem:opt_email>
<!--Optional:-->
<tem:opt_mobile>?</tem:opt_mobile>
<!--Optional:-->
<tem:opt_address>?</tem:opt_address>
<!--Optional:-->
<tem:opt_detail>?</tem:opt_detail>
</tem:api_paynow_authentication_new>
Вот код Савона:
class Order < ActiveRecord::Base
def initialize(ord)
client = Savon::Client.new do
wsdl.endpoint = "http://demo.paysbuy.com/api_paynow/api_paynow.asmx"
wsdl.namespace = "http://tempuri.org/"
end
response = client.request(:web,:api_paynow_authentication_new) do
soap.body = {psbID: "8303545188", username: "demo@paysbuy.com", secureCode: "1586093a8f80cbb5003001b42f0eeb7c", inv: "2009060101", itm: "Description of product", amt: "5", paypal_amt: "5", curr_type: "TH", com: "FbRy1+sLKnl4JpuwQ6D+sg==", method: "1", language: "T", resp_front_url: "https://www.paysbuy.com/receiveresponse/Result.aspx", resp_back_url: "https://www.paysbuy.com/receiveresponse/ResultReg.aspx"}
end
end
end
Я получаю эти ошибки в журнале разработки:
Started GET "/orders" for 127.0.0.1 at 2012-02-05 01:22:45 +0700
Processing by OrdersController#index as HTML
Completed 500 Internal Server Error in 2031ms
Savon::SOAP::Fault ((soap:Client) System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: apiPaynowAuthenticationNew.
Я также пробовал тестировать с использованием IRB. Я использовал следующие команды:
client = Savon::Client.new("http://demo.paysbuy.com/api_paynow/api_paynow.asmx?WSDL")
client.request :web, :api_paynow_authentication_new, body: {psbID: "8303545188", username: "demo@paysbuy.com", secureCode: "1586093a8f80cbb5003001b42f0eeb7c", inv: "2009060101", itm: "Description of product", amt: "5", paypal_amt: "5", curr_type: "TH", com: "FbRy1+sLKnl4JpuwQ6D+sg==", method: "1", language: "T", resp_front_url: "https://www.paysbuy.com/receiveresponse/Result.aspx", resp_back_url: "https://www.paysbuy.com/receiveresponse/ResultReg.aspx"}
Отправлено следующее содержимое:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://tempuri.org/">
<soapenv:Body>
<ins0:api_paynow_authentication_new>
<ins0:psbID>8303545188</ins0:psbID>
<ins0:username>demo@paysbuy.com</ins0:username>
<ins0:secureCode>1586093a8f80cbb5003001b42f0eeb7c</ins0:secureCode>
<ins0:inv>2009060101</ins0:inv>
<ins0:itm>Description of product</ins0:itm>
<ins0:amt>5</ins0:amt>
<web:paypalAmt>5</web:paypalAmt>
<web:currType>TH</web:currType>
<ins0:com>FbRy1+sLKnl4JpuwQ6D+sg==</ins0:com>
<ins0:method>1</ins0:method>
<ins0:language>T</ins0:language>
<web:respFrontUrl>https://www.paysbuy.com/receiveresponse/Result.aspx</web:respFrontUrl>
<web:respBackUrl>https://www.paysbuy.com/receiveresponse/ResultReg.aspx</web:respBackUrl>
</ins0:api_paynow_authentication_new></soapenv:Body>
</soapenv:Envelope>
и следующая ошибка:
D, [2012-02-05T01:48:25.473283 #18610] DEBUG -- : HTTPI executes HTTP POST using the net_http adapter
D, [2012-02-05T01:48:25.817349 #18610] DEBUG -- : SOAP response (status 500):
D, [2012-02-05T01:48:25.817420 #18610] DEBUG -- : <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault> <faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at api_paynow.api_paynow_authentication_new(String psbID, String username, String secureCode, String inv, String itm, Double amt, String paypal_amt, String curr_type, String com, String method, String language, String resp_front_url, String resp_back_url, String opt_fix_redirect, String opt_fix_method, String opt_name, String opt_email, String opt_mobile, String opt_address, String opt_detail) in d:\api_paynow\App_Code\Service.cs:line 191
--- End of inner exception stack trace ---</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
Savon::SOAP::Fault: (soap:Server) System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Что я делаю не так?