[英]Rails: Request to SOAP using Savon: Unable to process request
For learning purposes, I am trying the gem Savon to get information from the GlobalWeather SOAP Webservice. 出于学习目的,我尝试使用Savon来从GlobalWeather SOAP Web服务获取信息。 http://www.webservicex.net/globalweather.asmx?WSDL
http://www.webservicex.net/globalweather.asmx?WSDL
I am able to connect to the API and retrieve the operations: 我能够连接到API并检索操作:
[:get_weather, :get_cities_by_country]
But then when I try to make the call passing the message I get this error about the parameter not being passed: 但是然后当我尝试通过消息传递呼叫时,出现有关未传递参数的错误:
Savon::SOAPFault in CitiesController#index
(soap:Server) System.Web.Services.Protocols.SoapException: Server was unable
to process request. ---> System.Data.SqlClient.SqlException: Procedure or
function 'getWCity' expects parameter '@CountryName', which was not
supplied. at WebServicex.GlobalWeather.GetCitiesByCountry(String
CountryName) --- End of inner exception stack trace ---
My controller cities code is as follows: 我的控制器城市代码如下:
class CitiesController < ApplicationController
def index
@operations = client.operations
@response = client.call(:get_cities_by_country, message: { CountryName:"Spain" })
end
def client
Savon.client(wsdl: 'http://www.webservicex.net/globalweather.asmx?WSDL')
end
end
I think the problem might be related to how the hash message gets converted to camelCase according to the docs, so I tried to use the global option convert_request_keys_to :none but nothing different happened. 我认为问题可能与根据文档将哈希消息如何转换为camelCase有关,因此我尝试使用全局选项convert_request_keys_to:none,但没有发生任何不同的情况。
class CitiesController < ApplicationController
def index
@operations = client.operations
client = client do
convert_request_keys_to :none
end
@response = client.call(:get_cities_by_country, message: { CountryName: "Spain" })
end
def client
Savon.client(wsdl: 'http://www.webservicex.net/globalweather.asmx?WSDL')
end
end
I figure this out, It had to do indeed with convert_request_keys_to option, but it should be passed within the Savon::client call 我弄清楚了,它确实与convert_request_keys_to选项有关,但是应该在Savon :: client调用中传递它
def client
Savon.client(wsdl: 'http://www.webservicex.net/globalweather.asmx?WSDL', convert_request_keys_to: :none)
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.