大家好我試圖使用SSL,客戶端證書和基本身份驗證向受保護的wsdl和web服務發出一個簡單請求。使用SSL基本認證和客戶端證書幫助SOAP響應
下面的代碼
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.8.7?我有一個類似的問題獲得自簽名證書。 – r3nrut 2010-12-16 16:39:52