Ruby 使用ssl基本身份验证和客户端证书帮助Soap响应

Ruby 使用ssl基本身份验证和客户端证书帮助Soap响应,ruby,soap,ssl,certificate,Ruby,Soap,Ssl,Certificate,您好,我正在尝试使用ssl、客户端证书和基本身份验证向受保护的wsdl和web服务发出一个简单的请求 这是密码 require 'savon' client = Savon::Client.new "https://example.com/service?wsdl" client.request.http.ssl_client_auth( :cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")), :key =>

您好,我正在尝试使用ssl、客户端证书和基本身份验证向受保护的wsdl和web服务发出一个简单的请求

这是密码

require 'savon'

client = Savon::Client.new "https://example.com/service?wsdl"

client.request.http.ssl_client_auth(
:cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
:key => OpenSSL::PKey::RSA.new(File.read("key.pem")),
:verify_mode => OpenSSL::SSL::VERIFY_NONE
)
client.request.basic_auth "User", "Password"

response = client.AddCustomer |soap|
soap.body = {
:Channel => 0,
:tel => '34567',
:id => '597118125',
:paymentMode => 1,
:Alias => 666,
:flag => 0
}

puts response.to_xml
使用soapUI的工作测试信封是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mov="http://www.example.com/services/">
<soapenv:Header/>
<soapenv:Body>
<asd:AddCustomer>
<Channel>0</idChannel>
<tel>12344</msisdn>
<id>59711</idIssuer>
<paymentMode>1</paymentMode>
<Alias>666</idAlias>
<flag>0</flagPrivacy>
</asd:AddCustomer>
</soapenv:Body>
</soapenv:Envelope>

0
12344
59711
1.
666
0
当我运行代码时,出现以下错误:

method_missing': undefined method `AddCustomer' for #<Savon::Client:0x8abec08>
方法_缺失:未定义的方法“AddCustomer”#

试着打印出以下内容,或者只在irb中打印即可

client.wsdl.soap_actions

我猜你会发现AddCustomer不是其中之一。它可能已更改为类似于add_customer的内容。

您是对的,但现在在从AddCustomer更改为add_customer后,我收到以下错误:savon/soap.rb:164:在输入_数组中:“AddCustomer”的未定义方法“map”:字符串(NoMethodError)Ok SOLVED!!至少有3个问题:-我的ruby是1.9.1,现在是1.8.7-wsdl中的端点是错误的-我必须使用@inorder来发送正确的键和值序列。谢谢你的时间不是答案,但我不能评论,我很好奇为什么你不得不将ruby降级到1.8.7?我在获取自签名证书时遇到了类似的问题。