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

时间:2010-02-05 17:36:17

标签: 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 => 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>

当我运行我的代码时,我收到此错误:

method_missing': undefined method `AddCustomer' for #<Savon::Client:0x8abec08>

1 个答案:

答案 0 :(得分:3)

尝试打印出以下内容 - 或者只是在irb中执行

client.wsdl.soap_actions

我猜你会发现AddCustomer不是一个。它可能已经改为add_customer。