如何在 Ruby 中从 Savon 调用此安全 Web 服务 WDSL?
我有一些用于访问安全 Web 服务的可用 PHP 示例(见下文)。我正在尝试使用 Savon 访问网络服务。首先,我尝试了:
>> client = Savon::Client.new("https://secure.service.com/soa/soap/?WSDL")
=> #<Savon::Client:0x114053358 @wsdl=#<Savon::WSDL:0x1140532b8 @request=#<Savon::Request:0x1140532e0 @endpoint=#<URI::HTTPS:0x114053038 URL:https://secure.service.com/soa/soap/?WSDL>, @proxy=#<URI::Generic:0x114052fc0 URL:>>>, @request=#<Savon::Request:0x1140532e0 @endpoint=#<URI::HTTPS:0x114053038 URL:https://secure.service.com/soa/soap/?WSDL>, @proxy=#<URI::Generic:0x114052fc0 URL:>>>
第一个问题,SOAP 操作似乎是空的:
>> client.wsdl.soap_actions
warning: peer certificate won't be verified in this SSL session
=> []
并尝试使用 wsse 凭证访问 Web 服务,如下所示:
>> client = Savon::Client.new do |wsdl, http|
?> wsdl.document = "https://secure.service.com/soa/soap/?WSDL"
>> wsdl.wsse.credentials "user", "encrypted-md5-string"
>> end
结果:
ArgumentError: wrong number of arguments (0 for 1)
从下面的 Ruby 中的 PHP 示例中可以得到什么,以设置一些基本请求网络服务?
PHP 示例:
$foo = "+++hashkey+++";
$authUser = "user";
$authPass = "password";
$passphrase = md5($foo.$authPass.".wsdl");
echo "User: ".$authUser."<br>";
echo "Passphrase: ".$foo.$authPass.".wsdl<br>";
echo "Digest Passphrase: ".$passphrase."<br>";
$soapClient = new SoapClient( "https://secure.service.com/soa/soap/?WSDL",
array( "exceptions" => true,
"cache_wsdl" => WSDL_CACHE_NONE,
"login" => $authUser,
"password" => $passphrase));
$param = new stdClass();
$param->bankaccount = "1111111";
$param->bankcountry = "US";
$soaMethod = "SoaBank.getBank";
$soaParams = array($param);
$result = $soapClient->__soapCall($soaMethod, $soaParams);
print "<h1>Result</h1>";
print_r($result);
I have some working PHP example (see below) for accessing a secure webservice. I am trying to access the webservice with Savon. First, I tried:
>> client = Savon::Client.new("https://secure.service.com/soa/soap/?WSDL")
=> #<Savon::Client:0x114053358 @wsdl=#<Savon::WSDL:0x1140532b8 @request=#<Savon::Request:0x1140532e0 @endpoint=#<URI::HTTPS:0x114053038 URL:https://secure.service.com/soa/soap/?WSDL>, @proxy=#<URI::Generic:0x114052fc0 URL:>>>, @request=#<Savon::Request:0x1140532e0 @endpoint=#<URI::HTTPS:0x114053038 URL:https://secure.service.com/soa/soap/?WSDL>, @proxy=#<URI::Generic:0x114052fc0 URL:>>>
First problem, SOAP actions seem to be empty:
>> client.wsdl.soap_actions
warning: peer certificate won't be verified in this SSL session
=> []
And trying to access the webservice with wsse credentials like this:
>> client = Savon::Client.new do |wsdl, http|
?> wsdl.document = "https://secure.service.com/soa/soap/?WSDL"
>> wsdl.wsse.credentials "user", "encrypted-md5-string"
>> end
results in:
ArgumentError: wrong number of arguments (0 for 1)
What could be taken from this working PHP example below in Ruby, to set some basic requests to the webservice?
PHP example:
$foo = "+++hashkey+++";
$authUser = "user";
$authPass = "password";
$passphrase = md5($foo.$authPass.".wsdl");
echo "User: ".$authUser."<br>";
echo "Passphrase: ".$foo.$authPass.".wsdl<br>";
echo "Digest Passphrase: ".$passphrase."<br>";
$soapClient = new SoapClient( "https://secure.service.com/soa/soap/?WSDL",
array( "exceptions" => true,
"cache_wsdl" => WSDL_CACHE_NONE,
"login" => $authUser,
"password" => $passphrase));
$param = new stdClass();
$param->bankaccount = "1111111";
$param->bankcountry = "US";
$soaMethod = "SoaBank.getBank";
$soaParams = array($param);
$result = $soapClient->__soapCall($soaMethod, $soaParams);
print "<h1>Result</h1>";
print_r($result);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 Savon 2,您可以使用
:ssl_verify_mode =>; :无
For Savon 2 you can use
:ssl_verify_mode => :none
尝试关闭 ssl 验证:
Try turning off ssl verification: