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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-06 10:22 UTC
Re: Newbie automation testing web services with ruby
On 6 Jan 2009, at 05:17, winstan wrote:> > 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. >You might want to try the ruby talk list as this isn''t actually a rails question. Fred> 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 > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Fred, Ah my mistake, started new discussion on the wrong window. Thanks for pointing it out to me. Lucas On Jan 6, 9:22 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 6 Jan 2009, at 05:17, winstan wrote: > > > > > 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. > > You might want to try the ruby talk list as this isn''t actually a > rails question. > > Fred > > > > > 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- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---