如何在 Ruby 中从 Savon 调用此安全 Web 服务 WDSL?

发布于 2025-01-01 14:17:10 字数 1997 浏览 1 评论 0原文

我有一些用于访问安全 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情绪少女 2025-01-08 14:17:10

对于 Savon 2,您可以使用 :ssl_verify_mode =>; :无

Savon.client(:wsdl => 'https://blahService?wsdl', :ssl_verify_mode => :none)

For Savon 2 you can use :ssl_verify_mode => :none

Savon.client(:wsdl => 'https://blahService?wsdl', :ssl_verify_mode => :none)
淡淡的优雅 2025-01-08 14:17:10

尝试关闭 ssl 验证:

    client = Savon::Client.new("http://wsdl") do
      http.auth.ssl.verify_mode = :none          
    end

Try turning off ssl verification:

    client = Savon::Client.new("http://wsdl") do
      http.auth.ssl.verify_mode = :none          
    end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文