# Calling SOAP based Web Services over SSL

**URL:** <https://www.ruby-forum.com/t/calling-soap-based-web-services-over-ssl/96277>\
**Category:** Rails\
**Created:** [June 27, 2006, 9:33pm UTC](https://www.ruby-forum.com/t/calling-soap-based-web-services-over-ssl/96277 "2006-06-27T21:33:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Healey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eada6e/32.png) [@Tom\_Healey](https://www.ruby-forum.com/u/Tom_Healey)\
**Post date:** [June 27, 2006, 9:33pm UTC](https://www.ruby-forum.com/t/calling-soap-based-web-services-over-ssl/96277/1 "2006-06-27T21:33:45Z")

</div>

Ok, here we go.

1. I am trying to talk to a soap web service @ the url  
[https://rsvcstage.e2ma.net/emmaTestCalls](https://rsvcstage.e2ma.net/emmaTestCalls)
2. I can talk to the web service in plain ruby if I:  
2.1) disable site ruby (by renaming the site\_ruby directory to  
something else)  
2.2) use the WDSLDriverFactory instead of an actionwebservice  
The working ruby code looks like this:

* * *

```
wsdl_url = "https://rsvcstage.e2ma.net/emmaTestCalls.wsdl"
soap = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
result = soap.sayHello
puts "The result from sayHello is:" + result
result = soap.testStringParam("Hello from darden")
puts "The result from testStringParam(string my_string) is:" + result

```

* * *

1. The “equivalent” ruby code in rails fails. The ruby on rails code  
looks like:

* * *

def hello  
soap\_client =  
SOAP::WSDLDriverFactory.new(“[https://rsvcstage.e2ma.net/emmaTestCalls.wsdl](https://rsvcstage.e2ma.net/emmaTestCalls.wsdl)”)  
driver = soap\_client.create\_rpc\_driver  
driver.generate\_explicit\_type = true  
@retVal = driver.sayHello()

* * *

the results for that code is:

* * *

Processing EmmaTestController#hello (for 127.0.0.1 at 2006-06-27  
14:47:49) [GET]  
Session ID: 613f45340158044b3c25a7eb029e0874  
Parameters: {“action”=\>“hello”, “controller”=\>“emma\_test”}  
Error occurred in sayHello:uninitialized constant WSDLDriverFactory  
Rendering emma\_test/hello  
Completed in 0.00010 (10000 reqs/sec) | Rendering: 0.00000 (0%) | 200 OK  
[[http://localhost/emma\_test/hello](http://localhost/emma_test/hello)]

* * *

which I was told was because the factory could not resolve the https.  
As a test to ensure that i could write something that would talk soap I  
created a call to google  
that looked like this:

* * *

def googleSearch  
soap\_client =  
SOAP::WSDLDriverFactory.new(“[http://api.google.com/GoogleSearch.wsdl](http://api.google.com/GoogleSearch.wsdl)”)  
driver = soap\_client.create\_rpc\_driver  
driver.generate\_explicit\_type = true  
query=params[:query]  
key = “this is the place for my key”  
@retVal = driver.doGoogleSearch(key, query, 0, 10, false,“”, false,  
“”, “”, “”)  
rescue Exception =\> exc  
logger.error(“Error occurred in googleSearch:” + exc.message)  
end

* * *

Ok, so I then tried to use actionwebservice’s driver\_options to include  
ssl options.  
I also dloaded QuickCert to generate leys and loaded them into my public  
directory of my web server. That code looked like this:

* * *

def hello  
opts = {}  
opts[‘protocol.http.ssl\_config.verify\_mode’] =  
‘OpenSSL::SSL::VERIFY\_PEER’  
opts[‘protocol.http.ssl\_config.client\_cert’] =  
‘public/healeyt/cert\_healeyt.pem’  
opts[‘protocol.http.ssl\_config.client\_key’] =  
‘public/healeyt/healeyt\_keypair.pem’  
opts[‘protocol.http.ssl\_config.ca\_file’] = ‘public/CA’  
soap\_client = ActionWebService::Client::Soap.new(EmmaApi,  
‘[https://rsvcstage.e2ma.net/emmaTestCalls](https://rsvcstage.e2ma.net/emmaTestCalls)’, :driver\_options =\>  
opts).create\_rpc\_driver  
soap\_client.generate\_explicit\_type = true  
@retVal = soap\_client.sayHello()  
rescue Exception =\> exc  
logger.error(“Error occurred in sayHello:” + exc.message)  
end

* * *

And the result from that was SSL not supported.

* * *

Processing EmmaTestController#hello (for 127.0.0.1 at 2006-06-27  
15:08:11) [GET]  
Session ID: 613f45340158044b3c25a7eb029e0874  
Parameters: {“action”=\>“hello”, “controller”=\>“emma\_test”}  
Error occurred in sayHello:SSL not supported  
Rendering emma\_test/hello  
Completed in 0.01500 (66 reqs/sec) | Rendering: 0.00000 (0%) | 200 OK  
[[http://localhost/emma\_test/hello](http://localhost/emma_test/hello)]

* * *

So then I tried to make a secure webrick server based the code in this  
email:  
[http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html](http://lists.rubyonrails.org/pipermail/rails/2006-January/012432.html)  
and put it in the commands directory with the other server.

I copied script/server script to script/secure and pointed it to the  
secure\_webrick script in the previous step.

That didn’t work.  
After all this I am convinced of 2 things:

1. that this is harder than it needs to be
2. I am screwing up in so major way

and I am pleading for help.

Thanks in advance.  
Tom
