Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Webservices Testing Using SOAP UI

Webservices Testing Using SOAP UI

Ratings: (0)|Views: 993|Likes:
Published by reachmsm

More info:

Published by: reachmsm on Jul 29, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Service-oriented architecture (SOA)
web services
are becoming more and more popularin many development projects. In Java or .NET, exposing your business logic component as aweb service is as simple as adding a few metadata annotations. Likewise, once you have aweb service, you can use any client to consume it, right?Before you make all your web services available to the public, however, you need to makesure they work. The only way to do this is by writing functional tests for your web services.So much for the theory. I have seen very few projects that actually spend any time testing theweb services they expose. In most cases, these web services are tested as part of the totalsystem, using whatever user interface is provided. I myself was guilty of doing this before Idiscovered
.From the day I discovered SoapUI almost 4 years back, however nothing stops me fromwriting functional tests for these web services. SoapUI makes it almost tempting to write testsusing their GUI. You can create new test suites, add test cases, and add asserts to your testcases. This tool is easy to use; you don’t have to be a Java developer to write functional tests.The tests you write in SoapUI are very manageable. I constantly hear developers saying, Ihave no clue what this test does; I didn’t write it.Tests need to be maintained just as yourcode does. Once you download and install SoapUI, you can have functional tests up andrunning in minutes. Can you write the same test in minutes without SoapUI? No way.Developers too frequently write tests with no assert statements. Why even bother writing atest without asserts? With SoapUI you can easily add many types of assertions. You can addassert statements with the click of a button. If the ones within SoapUI aren’t sufficient foryour requirements, I am going to show you how to use Groovy within SoapUI, which willmake your testing even easier.OK. You write you tests using SoapUI, add some asserts, and actually run them occasionally.This is better than nothing, but still largely pointless. Tests should be integrated with yourbuild and should be able to be run with one click. Yes, I confess, I am the laziest developeryou will ever see. Why bother doing the same thing over and over again when we can do thesame thing with the click of a button?If you have automated your builds and they are running as part of your ContinuousIntegration, of course, there even isn’t a single click to worry about (now that’s lazy!). SoapUIcomes in handy here as well. You can run the test suites and all the test cases you createdwithin it and above all you can fail the build just like you would when any other unit testfails. Cool, isn’t it? I’m excited, are you?OK. Things are better. Now you have your tests, you have some groovy scripts, and it’s allintegrated with CI. What use are your tests without reports? SoapUI comes to our rescue hereas well. You can generate JUnit reports.
Let’s see how we can accomplish all this. In this article I am going to cover Functional WebServices testing using SoapUI, but don’t worry, there will be more articles on
SoapUI andGroovy
as well as on
SoapUI and Continuous Integration
in the coming weeks.Before we begin actually writing tests, we need two things first:
Download and install SoapUI fromhere. 
Next, let’s get a
. I wanted to actually focus more on SoapUI rather thanany one technology to publish your business logic as web services. So, I took the easy routeand found out some interesting things about this publicly available web service.According to the NOAA web site, this web service allows you to get weather data. It has ninefunctions. Here is the actual wsdl from the web site:
Now that we have SoapUI downloaded and a web service which we can test, let’s startworking.
Create a new project within SoapUI; give it a name; and copy and paste the WSDL URLwithin it. Things should look like this:
Once you have created the project successfully you should be able to see all nine functionsthat are provided to us by NOAA. We are only going to use three of them, as seen below inthe screen shot:
Now it’s time to run these requests to ensure that they actually work. Double click on
Request 1
. An editor will open up for the
request. Enter the zip code foryour city. I did 20904 for Silver Spring. Click the Green button on the Request 1 editor andyou should be able to see the response on the right hand side of the editor.Try a few more requests with the following data:
NDFDgenByDay Request 1
1.<ndf:NDFDgenByDaysoapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">2. <latitude xsi:type="xsd:decimal">39.0138</latitude>3. <longitude xsi:type="xsd:decimal">-77.0242</longitude>4. <startDate xsi:type="xsd:date">2008-05-07</startDate>5. <numDays xsi:type="xsd:integer">1</numDays>6. <format xsi:type="dwml:formatType"xmlns:dwml="http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd">12 hourly</format>7. </ndf:NDFDgenByDay>
b. NDFDgenByDayLatLonList Request 1

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Ting Zhang liked this
goga1234 liked this
goga1234 liked this
reachmsm liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->