Testing the Web Services (Part One)

April 25, 2011


Lets begin with introduction of the tool I am going to use for testing web services, that is SoapUI:

“SoapUI is a free and open source cross-platform Functional Testing solution. With an easy-to-use graphical interface, and enterprise-class features, SoapUI allows you to easily and rapidly create and execute automated functional, regression, compliance, and load tests. In a single test environment, SoapUI provides complete test coverage and supports all the standard protocols and technologies.”

I will not explain all the features of SoapUI so please go through the detailed documentation of SoapUI available on eviware website:

http://www.eviware.com/soapUI/what-is-soapui.html

Download SoapUI from the following site (the latest versions are backward compatible):

Download SoapUI

I am going to use a publicly available WSDL (Bing) for the tutorials so that we all are on the same page, please note the WSDL URL:

http://api.bing.net/search.wsdl

You can also get help from the following documentation (Bing API Basics):

http://www.bing.com/developers/s/API%20Basics.pdf

Also you need to create an AppId to use Bing API because it is a required field in the WSDL, you can do so by signing up here:

http://www.bing.com/developers/createapp.aspx

Lets Start with creating a new project in SoapUI:

  1. Click File > New SoapUI Project
  2. Type a project name
  3. Insert the WSDL EndPoint in the WSDL Text Box (http://api.bing.net/search.wsdl)
  4. Leave all the check boxes unchecked except for “Create sample requests for all operations”.
  5. Click OK.

Now we are ready to use and test the web services. Since the Bing API has also one operation in the WSDL (Search()) expand it, you will see a Request option under it, double clicking the “Request” will open the editor window:

You would see plenty of elements available in the request for different purposes such as Web Search, Image Search etc, because exploring the Bing API is beyond our scope we will not discover them all. We’ll create a simple web search using minimal required fields in the Request. Copy/Paste the following request in your request editor (Provide your AppId which you created using the steps provided above) and execute it with the help of the Play/Execute button available in the upper left corner of the editor:

Request:
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:sear=”http://schemas.microsoft.com/LiveSearch/2008/03/Search”&gt;
<soapenv:Header/>
<soapenv:Body>
<sear:SearchRequest>
<sear:parameters>
<sear:Query>bing</sear:Query>
<sear:AppId>D5D9ACDF440248EA41EC324C3B867AFDE63319CB</sear:AppId>
<sear:Sources>
<!–Zero or more repetitions:–>
<sear:SourceType>web</sear:SourceType>
</sear:Sources>
<!–Optional:–>
<sear:Web>
<!–Optional:–>
<sear:Offset>0</sear:Offset>
<!–Optional:–>
<sear:Count>1</sear:Count>
</sear:Web>
</sear:parameters>
</sear:SearchRequest>
<!–soapenv:Body>–>
<!–soapenv:Envelope>–>

Executing it would give you the following response:

Response:

<!–pageview_candidate–>
<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
<soapenv:Body>
<SearchResponse xmlns=”http://schemas.microsoft.com/LiveSearch/2008/03/Search”&gt;
<parameters>
<Version>2.2</Version>
<Query>
<SearchTerms>bing</SearchTerms>
</Query>
<Web>
<Total>911000</Total>
<Offset>0</Offset>
<Results>
<WebResult>
<Title>Bing</Title>
<Description>Bing is a search engine that finds and organizes the answers you need so you can make faster, more informed decisions.</Description>
<Url>http://www.bing.com/</Url&gt;
<CacheUrl>http://cc.bingj.com/cache.aspx?q=bing&amp;d=4523786176561420&amp;w=7c43e585,779e3b42</CacheUrl&gt;
<DisplayUrl>www.bing.com</DisplayUrl>
2011-04-24T16:32:00Z
<DeepLinks>
<DeepLink>
<Title>Search History</Title>
<Url>http://www.bing.com/profile/history?FORM=Z9LH12</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Search History</Title>
<Url>http://www.bing.com/profile/history</Url&gt;
</DeepLink>
<DeepLink>
<Title>United States</Title>
<Url>http://www.bing.com/worldwide.aspx?FORM=WHLH</Url&gt;
</DeepLink>
<DeepLink>
<Title>Local – Bing News</Title>
<Url>http://www.bing.com/news/search?q=&amp;p1=%5bNewsVertical+Category%3d%22rt_Local%22%5d</Url&gt;
</DeepLink>
<DeepLink>
<Title>Maps</Title>
<Url>http://www.bing.com/maps/</Url&gt;
</DeepLink>
<DeepLink>
<Title>Entertainment</Title>
<Url>http://www.bing.com/entertainment?FORM=Z9LH11</Url&gt;
</DeepLink>
<DeepLink>
<Title>Business – Bing News</Title>
<Url>http://www.bing.com/news/search?q=&amp;p1=%5bNewsVertical+Category%3d%22rt_Business%22+View%3d%220%22%5d</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Community</Title>
<Url>http://www.bing.com/community/blogs/search/archive/2009/08/17/welcome-home.aspx?&amp;form=pgbar1</Url&gt;
</DeepLink>
<DeepLink>
<Title>Sports – Bing Videos</Title>
<Url>http://www.bing.com/videos/browse/sports?q=browse:sports</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Maps For India</Title>
<Url>http://www.bing.com/mapindia/?FORM=Z9LH3</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing تفضيلات</Title>
<Url>http://www.bing.com/settings.aspx?sh=5&amp;ru=%2f&amp;FORM=FLLH</Url&gt;
</DeepLink>
<DeepLink>
<Title>Travel</Title>
<Url>http://www.bing.com/travel/</Url&gt;
</DeepLink>
<DeepLink>
<Title>Bing Preferences</Title>
<Url>http://www.bing.com/settings.aspx?sh=5&amp;ru=%2f&amp;FORM=FTLH</Url&gt;
</DeepLink>
</DeepLinks>
</WebResult>
</Results>
</Web>
</parameters>
</SearchResponse>
<!–soapenv:Body>–>
<!–soapenv:Envelope>–>

Success… :) Response seem to be valid, lets check manually if it is really valid …

I requested a simple web search using Bing for the keyword “Bing”, and restricted the count to 1 which means show me only 1 result. Notice that some of the elements have values such as under the <WebResult> element we have several other elements such as Title, Description, URL etc each having their own values.

Note: This was the most Basic tutorial of Creating a new Web-Services project in SoapUI, Executing the Request and Receiving the Response. I intend to share this series from Basic to Advanced so that beginners can learn as well.

See you in the next part, where we’ll see how to put some useful assertions to confirm the response.

Happy Testing !!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: