views:

621

answers:

1

Hello all I'm trying to issue a simple request to a protected wsdl and web service using ssl, client certificates and basic authentication.

Here's the code

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

and the working tested envelope using soapUI is:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mov="http://www.example.com/services/"&gt;
<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>

When i run my code I get this error:

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

try printing out the following - or just do it in irb

client.wsdl.soap_actions

I'm guessing you'll see that AddCustomer is not one. It has probably been changed to something like add_customer.

Beanish
You were right but now after changing from AddCustomer to add_customer, I received the following error:savon/soap.rb:164:in input_array': undefined method `map' for "addCustomer":String (NoMethodError)
acemutha
Ok SOLVED!! there were at least 3 problems:- My ruby was 1.9.1 and now is 1.8.7- the endpoint in wsdl was wrong - I had to use @inorder to send the correct sequence of keys and values.Thanks for your time
acemutha