Hi Guys, Another question for you bunch as you seem to be the most helpful out there (have posted on the comp.lang.ruby group with no response).
I have been trying to make requests to the webserver via SOAP adapting an example i had found on another site. Am i looking at the right thing for what i want? This is what i am trying to complete 1: Making requests and receiving responses from 4 different web services (v1, v2, v3, v4) 2: v2 & v4 web services require a client certificate 3: Phase one I want to make a series of requests to different methods and do a diff on the response and an xml saved locally to ensure the structure hasn’t changed and if it has, what’s different. Am I going down the right path using SOAP? As I said I have already started using an example that I found on the net… if you care to take a look at the issues I have been having with that please take a look at the post on the comp.lang.ruby group I made: http://groups.google.com.au/group/comp.lang.ruby/browse_thread/thread/ad39567636611a6a?hl=en# Thanks again guys! On Dec 24 2008, 4:05 am, Bret Pettichord <[email protected]> wrote: > I was testing an rss feed and used Mechanize + Hpricot to do so. I got > the url from the application using Watir and then passed it to Mechanize > to get the page and then used Hpricot to validate it. > > Bret > > > > srinivas subramanian wrote: > > Hi, > > > Its been quite some time, since i've started using Watir. Its awesome. > > I've used Hpricot to test xmls. It worked out well for me. Please > > refer:http://code.whytheluckystiff.net/hpricot/ > > > Thanks, > > Srinivas > > > On Tue, Dec 23, 2008 at 5:25 AM, winstan > > <[email protected] > > <mailto:[email protected]>> wrote: > > > Hi Bret, > > > No i havent used Mechanize. Nor have i heard of it to be honest. > > Before i jump into it and start playing around with it, i would like > > to ask have you used it in the means in which im trying to access the > > xmldefined above? > > > Cheers > > > On Dec 23, 3:08 am, Bret Pettichord <[email protected] > > <mailto:[email protected]>> wrote: > > > Have you considered using Mechanize instead of Watir? That's > > what I've > > > used when I've had to testXML. > > > > Bret > > > > winstan wrote: > > > > Hello Again, > > > > > After playing around with rexml with some of the URL's provided in > > > > this thread and other sites I have found I have established > > that you > > > > are in fact correct and that rexml would be the way to go. > > However, I > > > > am still making requests and receiving responses to and from > > the WS > > > > via the UI, and as such I am in need of a little more > > help/advice with > > > > this. > > > > > After making the request with specific attributes a response > > is served > > > > up from the WS and is opened in another IE window. I can > > attach to the > > > > new window with out a problem but from that point on I am > > unsure as to > > > > how to proceed with the use of rexml. Bellow is an example of some > > > > thing I tried but I assume because I am making the. > > > > > it 'Attaching to the new window and confirming that there was > > a VALID > > > > response from the web server' do > > > > @b2 = Watir::IE.attach(:url, 'http://privateurl.asmx/ > > > > wsresponse') > > > > @b2.maximize > > > >xml= @b2.html > > > > doc = REXML::Document.new(xml) > > > > WID = REXML::XPath.first(doc.root, '//WID/text()') > > > > WID == (data['WIDTestField']) > > > > > The reason I attempted "xml= @b2.html" is because when I view the > > > > source of the window that contains the response from the WS, > > it just > > > > shows theXML. Needless to say that didn't work, and I didn't > > really > > > > expect it to however I thought I would give it a shot. I then > > went to > > > > irb on the command line and had a look at what "@b2.html" actually > > > > looked like. I was expecting to see thexmlwithout formatting > > however > > > > there was a lot more to it than what the page source showed. This > > > > would explain the error message in my respec results.html: > > > > > #<REXML::ParseException: missing attribute quote > > > > Line: > > > > Position: > > > > Last 80 unconsumed characters: > > > > <SPAN class=b> </SPAN> <SPAN class=m></</SPAN><SPAN > > > > class=t>Client</SPAN>> > > > > c:/ruby/lib/ruby/1.8/rexml/parsers/baseparser.rb:345:in `pull' > > > > c:/ruby/lib/ruby/1.8/rexml/parsers/treeparser.rb:21:in `parse' > > > > c:/ruby/lib/ruby/1.8/rexml/document.rb:204:in `build' > > > > c:/ruby/lib/ruby/1.8/rexml/document.rb:42:in `initialize' > > > > ./tests/WsRequestClientByWid_test.rb:36:in `new' > > > > ./tests/WsRequestClientByWid_test.rb:36 > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_methods.rb:81:in `instance_eval' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_methods.rb:81:in `eval_block' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_methods.rb:15:in `execute' > > > > c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_methods.rb:12:in `execute' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_group_methods.rb:245:in `execute_examples' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_group_methods.rb:244:in `each' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_group_methods.rb:244:in `execute_examples' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/ > > > > example_group_methods.rb:141:in `run' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/ > > > > example_group_runner.rb:22:in `run' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/ > > > > example_group_runner.rb:21:in `each' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/ > > > > example_group_runner.rb:21:in `run' > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb: > > > > 115:in `run_examples' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/ > > > > command_line.rb:10:in `run' > > > > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > > > > c:/ruby/bin/spec:16:in `load' > > > > c:/ruby/bin/spec:16 > > > > ... > > > > missing attribute quote > > > > Line: > > > > Position: > > > > Last 80 unconsumed characters: > > > > <SPAN class=b> </SPAN> <SPAN class=m></</SPAN><SPAN > > > > class=t>Client</SPAN> > > > > Line: > > > > Position: > > > > Last 80 unconsumed characters: > > > > <SPAN class=b> </SPAN> <SPAN class=m></</SPAN><SPAN > > > > class=t>Client</SPAN> > > > > > Basically I was wondering if any one could suggest a way of me > > being > > > > able to use rexml without having to save any files and just > > using the > > > >xmlresponse on the second IE window that is opened as a > > result of the > > > > request. > > > > > Thanks again guys. I really appreciate your guidance. > > > > > On Dec 5, 3:37 am, "Richard Lawrence" <[email protected] > > <mailto:[email protected]>> wrote: > > > > >> You really don't want to be reinventingXMLparsing (badly) with > > > >> string substitution or regular expressions. Given a string > > with your > > > >>XMLin it, theREXMLcode to get the values you want would look > > > >> something like the following. You'll have to use something like > > > >> Net::Http to actually make the web service call to get the > > XMLstring. > > > >> There are some decent examples > > > > here:http://rubylearning.com/blog/2008/04/25/yahoo-web-services-in-ruby/. > > > > >> As Alex recommended, play around in irb with this to get a > > feel for it. > > > > >> require 'rexml/document' > > > > >>xml= '<?xmlversion="1.0" > > > ?><parent><firstName>Foo</firstName><lastName>Bar</lastName></parent>' > > > > >> doc =REXML::Document.new(xml) > > > > >> firstName =REXML::XPath.first(doc.root, '//firstName/text()') > > > >> lastName =REXML::XPath.first(doc.root, '//lastName/text()') > > > > >> Richard > > > > >> On Thu, Dec 4, 2008 at 4:38 AM, Alex Collins > > <[email protected] <mailto:[email protected]>> wrote: > > > > >>> A useful general principle if you are wondering if something > > will work > > > >>> is to try it. In Ruby, start IRB (type irb at the command > > line) then > > > >>> type your ruby code. Irb will show you the results after > > each line. > > > >>> You do not need $ signs (ruby global variable) but you must > > certainly > > > >>> quote your strings. However your code will not work as there > > is no - > > > >>> method for a string. > > > > >>> Instead, you could use the sub or gsub methods: > > > > >>> a = "aba" > > > >>> a.gsub 'a', 'c' > > > >>> => "cbc" > > > > >>> In the simple case, it sounds like you want to use a regular > > > >>> expression (regexp) to do pattern recognition. Results of > > matching are > > > >>> stores in MatchData objects. Something like: > > > > >>> re = /<pattern>(.*)<\pattern/>/ > > > >>> matchdata = string.match(re) > > > >>> puts matchdata.captures > > > > >>> However, if you want to do more than this you would be > > better using > > > >>> REXML as Richard suggested. Alternatively, use a tool > > designed for > > > >>> testingXMLwebservices eg SOAPUI. Watir is designed for testing > > > >>> websites. > > > > >>> You might want to read a ruby tutorial though to get a > > better idea of > > > >>> how to use ruby. > > > > >>> Hope this helps. > > > > >>> On 4 Dec 2008, at 06:40, winstan > > <[email protected] > > <mailto:[email protected]>> wrote: > > > > >>>> Would i be able to do some thing like this: > > > > >>>> $a = <ShortName>TESTA</ShortName> > > > >>>> $b = <ShortName> > > > >>>> $c = </ShortName> > > > >>>> $d = a - b > > > >>>> $e = d - c > > > > >>>> which in turn would make $e "TESTA"? > > > > >>>> On Dec 4, 4:55 pm, "Richard Lawrence" <[email protected] > > <mailto:[email protected]>> wrote: > > > > >>>>> Why are you accessing the web service using Watir and IE? > > Will end > > > >>>>> users of the web service access it with a browser? If not, > > and if > > ... > > read more »- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to [email protected] Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---
