# Newbie automation testing web services with ruby

**URL:** <https://www.ruby-forum.com/t/newbie-automation-testing-web-services-with-ruby/157057>\
**Category:** Ruby\
**Created:** [January 6, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/newbie-automation-testing-web-services-with-ruby/157057 "2009-01-06T23:59:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Winstanley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@Lucas\_Winstanley](https://www.ruby-forum.com/u/Lucas_Winstanley)\
**Post date:** [January 6, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/newbie-automation-testing-web-services-with-ruby/157057/1 "2009-01-06T23:59:37Z")

</div>

Hi all,

First post on this group and I hope you guys are as helpful as the  
other guys have been for me on the watir group. Fingers crossed.

I have been successfully making HTTP POST protocol requests via an in  
house GUI using watir REXML to parse and validate the data, however  
now I wish to make SOAP calls with ruby. I have been doing research  
for days on this and am in need of a little help.

Due to the sensitivity of the work I am carrying out I will be as  
detailed as possible with the actual code I am using but at times I  
may be a little vague so please don’t just pass by not knowing what  
I’m talking about but please take the time to ask me for some more  
information.

Ok so back to my research. I came across a good example for sending a  
request to the web service and just outputting the response. However  
the response kept returning the line: “Server did not recognize the  
value of HTTP Header SOAPAction:”… so further I went with my  
investigation.

Here is the code I have been trying to use (without my edits to the  
LOCALHOST\_ENDPOINT & request\_xml\_string):

require ‘soap/element’  
require ‘soap/rpc/driver’  
require ‘soap/processor’  
require ‘soap/streamHandler’  
require ‘soap/property’

LOCALHOST\_ENDPOINT = “[http://localhost:8080/services/Service](http://localhost:8080/services/Service)”  
request\_xml\_string = ‘xml…’

stream = SOAP::HTTPStreamHandler.new(SOAP::Property.new)  
header = SOAP::SOAPHeader.new  
body\_item = SOAP::SOAPElement.new(‘getResponse’, request\_xml\_string)  
body = SOAP::SOAPBody.new(body\_item)  
envelope = SOAP::SOAPEnvelope.new(header, body)

request\_string = SOAP::Processor.marshal(envelope)  
request = SOAP::StreamHandler::ConnectionData.new(request\_string)  
resp\_data = stream.send(LOCALHOST\_ENDPOINT, request, ‘getResponse’)

It would appear that the xml response that I am seeking doesn’t have  
a  
header and that it is not an essential element of an xml (I later  
learnt). EASY I thought, I will just comment out the header line and  
remove it from the envelope line, resulting in this:

stream = SOAP::HTTPStreamHandler.new(SOAP::Property.new)  
#header = SOAP::SOAPHeader.new  
body\_item = SOAP::SOAPElement.new(‘getResponse’, request\_xml\_string)  
body = SOAP::SOAPBody.new(body\_item)  
envelope = SOAP::SOAPEnvelope.new(body)

Again to no prevail, this is the output I get from SciTE:

c:/ruby/lib/ruby/1.8/soap/element.rb:246:in `encode': undefined method `length’ for #SOAP::SOAPBody:0x2d1dc04 (NoMethodError)  
from c:/ruby/lib/ruby/1.8/soap/generator.rb:129:in  
`encode_element' from c:/ruby/lib/ruby/1.8/soap/generator.rb:70:in `encode\_data’  
from c:/ruby/lib/ruby/1.8/soap/generator.rb:58:in `generate' from c:/ruby/lib/ruby/1.8/soap/processor.rb:30:in `marshal’  
from WsRequestClientByShortName\_test.rb:29

Now I’m really lost and don’t know what to do now.

Many thanks with anticipation, and I look forward to speaking with  
you  
all at some stage.

Lucas

---

<div class="post-metadata">

**Author:** ![Lucas\_Winstanley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@Lucas\_Winstanley](https://www.ruby-forum.com/u/Lucas_Winstanley)\
**Post date:** [January 8, 2009, 7:43am UTC](https://www.ruby-forum.com/t/newbie-automation-testing-web-services-with-ruby/157057/2 "2009-01-08T07:43:25Z")

</div>

> Ok so back to my research. I came across a good example for sending a  
> request to the web service and just outputting the response. However  
> the response kept returning the line: ï¿½Server did not recognize the  
> value of HTTP Header SOAPAction:ï¿½ï¿½ so further I went with my  
> investigation.

You could try soap4r or try and custom brew you own I suppose…  
-=r
