Newbie automation testing web services with ruby

Discussion in 'Ruby' started by Lucas Winstanley, Jan 6, 2009.

  1. 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
    Lucas Winstanley, Jan 6, 2009
    #1
    1. Advertising

  2. Lucas Winstanley

    Roger Pack Guest


    > 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
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Jan 8, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ECS Automation Administrator

    ECS: Elements of C++ Style Automation Testing

    ECS Automation Administrator, Nov 16, 2004, in forum: C++
    Replies:
    0
    Views:
    332
    ECS Automation Administrator
    Nov 16, 2004
  2. Replies:
    0
    Views:
    768
  3. apondu
    Replies:
    0
    Views:
    584
    apondu
    Jul 19, 2007
  4. lofenee

    Applet GUI testing automation

    lofenee, Jul 16, 2008, in forum: Java
    Replies:
    17
    Views:
    1,821
    lofenee
    Jul 18, 2008
  5. John
    Replies:
    4
    Views:
    415
Loading...

Share This Page