gpt4 book ai didi

ruby-on-rails - 如何在 Ruby 中从 Savon 调用此安全 Web 服务 WSDL?

转载 作者:太空宇宙 更新时间:2023-11-03 18:27:25 24 4
gpt4 key购买 nike

我有一些用于访问安全网络服务的有效 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 凭据访问网络服务:

>> 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);

最佳答案

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

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

关于ruby-on-rails - 如何在 Ruby 中从 Savon 调用此安全 Web 服务 WSDL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9098761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com