Newbie automation testing web services with ruby

  • Thread starter Lucas Winstanley
  • Start date
L

Lucas Winstanley

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"
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
 
R

Roger Pack

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top