JavaScript Menu by Deluxe-Menu.com
   Complex Web services

As we continuing to use more complex web services we are navigating to www.xignite.com For using Xignite you have to be registered to their web site. after registering you can use a service free, for about 100 times. i think is enough to practice this topic. So i selected a service called XigniteMetals a service that provides Real-time Gold and Precious Metal Spot Prices. The Servicehas 15 operations, so i selected an operation that we can fully test GetHistoricalSpotPrice  the operation, returns a historical spot price for a metal.

Xignite Web Services
"Xignite is the leading cloud services provider of on-demand, global financial market data and application components.   The Xignite financial Web services and mash-up platform helps companies build smarter websites and software applications in minutes with zero infrastructure investment and cost-effective subscription pricing.
Xignite fulfills more than one billion service requests per month and offers the broadest selection of financial Web services available today with more than 50 solutions covering domestic and global equities, commodities, currencies, fixed income and interest rates, company fundamentals, corporate information and more. Xignite solutions power mission-critical applications for financial websites, portfolio management, sales management, trading, investor relations, executive dashboards, ERP, accounting, e-commerce, and online games for more than 400 global clients, including Forbes.com, kaChing.com, NetSuite, Citi, GE Commercial Finance, ING, Starbucks, Wells Fargo and Wendy's. For more information, please visit Xignite at www.xignite.com or call 1-866-XML-SOAP."

Farris Pine
Xignite, Financial Web Services

Input Values

Xignite seems a very serious web service provider site, you don't have to understand WSDL structures and rules. Xignite itself provides the requested information, so you can easily understand the purpose, the input values or the return values of any operation and service. following an image from xignite web site, under the XigniteMetals Web Service, operation GetHistoricalSpotPrice

Output Values

8 different values returned from a single request. since that AsOfDate is always in the past the values are not changing and they are testable, as we want to test the service itself.

Capturing the WSDL

on the right menu, of the XigniteMetals service, click on the WSDL option. You can find the WSDL for all the services by adding '?WSDL' at the end of the URL for that service. For instance, the WSDL for XigniteMetals is: http://www.xignite.com/xMetals.asmx?WSDL

Testing the Service

Select from the QuickTest menu Automation / Web service Testing Wizard In the Set Security Options Screen select URL and paste the following wsdl location : http://www.xignite.com/xMetals.asmx?WSDL
click Next In the Select Service and Operations window, select only the GetHistoricalSpotPrice operation using the XigniteMetalsSoap port name. then click Next


In the Summary Screen check the add XML checkpoint option. For each operation, the wizard generates default argument values with the proper value types. For each automatically created checkpoint (tests only), the wizard generates a generic XML structure as a place holder for the expected XML return values. Before you can run your test, you must replace the default values with the appropriate values for your test.

7.1 - Modify Generated Code

Modify the generated code to retrieve real information, and you can add an additional validation step. After editing the parameters ( Select Gold "XAU", "EUR" and "3/13/2009" ) the run the test in Update Mode Show me how...
Then, on the Update Run dialog select the Update checkpoint and output value properties option only, and click OK.


   Enhancing the Web service Test - Static Data

After creating a basic test, we want to make improvements. we want to tes more metals, different currencies and different dates. since the specific checkpoint tests past values i will rename it to MetalsPast

To modify the existing checkpoint select checkpoit properties we select the keyword checkpoint from the keyword view and pressing the Checkpoint button or alternatively, for the Expert view, by selecting the Checkpoint Properties context menu.

Object Repository - Before
object repository state before renaming test object
Object Repository - After
object repository state after renaming test object

Parameterizing the XML Checkpoint

Outcome. Management field.
Identity. Management Field.
Delay. Management Field.
Symbol. Request symbol - combination of metal symbol and currency.
Type. metal symbol ( as input ).
Currency. Currency abbreviation ( as input ).
Date. Date of quote ( as input ).
First. The value of the first quote.
High. The value of the highest quote.
Low. The value of the lowest quote.
Last. The value of the last quote.

We are only testing the values of the following fields. since we excluding the administration fields.

Parameterize Checkpoint
parameterizing xml checkpoint to local datatable


Click image to watch a XML parameterizing demonstration:

before last step, we need to parameterize the input values for the service.

9.1 - Parameterized Web Service

And last, we need to parameterize the input values for the service. the input parameters retrieved from the local datasheet.



Click image to watch a Web Service parameterize demonstration:

on the last step, we are about to add new valid information.

we are running the test in Update Mode, when test finished we are going to see the following results:

And why is exactly the test ended with status warning?
We can see the in the thirs iteration, the structure of the xml was changed...

a little more reserch will lead us to the checkpoint update on iteration 3. and we'll see that the structure was really changed. a new administartion field Message was added by the service, and we can't control it. Because of that, the checkpoint will fail, when testing data that uses other currency than USD or EUR. this is the big disadvantage of using xml checkpoints. lack of flexibility. to solve the problem we have to find a workaround or another solution. since another solution involve xml manipulation, which is not on this article scope, i will show you how to make an efficient woraround.

Workaround

we need two types of checkpoints, one for the USD-EUR currency, and the other for the rest. in this case we are going to "duplicate" the checkpoint, and use it differently inside an If...Then clause.

SOAP Response
soap response addirional field

9.2 - Parameterized Conditional Web Service

And last, we need to parameterize the input values for the service. the input parameters retrieved from the local datasheet.


Updating expected Results

Before we can run the final test,we need to fill the expeced results. according this example and the goal of the test, all we need to do is to analyze the SOAP Response.

Expected Results Parameters
updating local datatable input parameters

Using Formulas in the Data Table

One interesting parameter is the Symbol. The symbol value is always a concatenation between the Type and the Currency
We can use Microsoft Excel formulas in the Data Table. This enables you to create contextually relevant data during the run session. it is also possible to use formulas as part of a checkpoint to check that objects created on-the-fly  (dynamically generated) or other variable objects in your Web page or application have the values you expect for a given context. When using formulas in a Data Table to compare values (generally in a checkpoint), the values you compare must be of the same type, for example integers, strings, and so forth.

We have finished to design the test, you can run the test now. don't forget to select Run on all rows for the action call propertes.

QTP Report
Conditional Web Service Checkpoint
WS Static Data Test Download
  • File Name: xignite1.zip
  • File Size: 47.1KB
  • File Version: 1.0
Click here to download ws static data test for QTP 10
   Enhancing the Web service Test - Dynamic Data

Testing Dynamic Data is a different story, unless you can predict each value exactly. So, when testing dynamic we want to test the rersponse structure and pattern values ( e.g numeric, range of values etc. )

Dynamic Data
GetHistoricalPriceResponse node Has exactly one child node named "GetHistoricalSpotPrice".
[ Show Me...]
GetHistoricalSpotPrice node Has exactly 3 attributes, the atttributes values, and exactly 11 children
[ Show Me...]
1st node name is Outcome The node has no children and no attributes, the value can be RequestError or Success ( Regular Expression: "RequestError|Success" )
[ Show Me...]
2nd node name is Identity The node has no children and no attributes, the value is always "IP"
[ Show Me...]
3rd node name is Delay The node has no children and no attributes, the value is floating numeric value( Regular Expression: "?[0-9.]+" )
[ Show Me...]
4th node name is Symbol The node has no children and no attributes, the value is a 6 uppercase letters( Regular Expression: "[A-Z]{6}" )
[ Show Me...]
5th and 6th nodes; names are Type and Currency The node has no children and no attributes, possible value 3 uppercase letters
[ Show Me...]
7th node name is Date The node has no children and no attributes, value is a m/d/yyyy pattern ( Regular Expression: "[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}" )
[ Show Me...]
First, High, Low, and Last Nodes has no children and no attributes, value is floating point or integer numeric values.

WS Dynamic Test Download
  • File Name: xignite2.zip
  • File Size: 46.9KB
  • File Version: 1.0
Click here to download ws dynamic data test for QTP 10

   Enhancing the Web service Test - Negative Testing

Terms like "negative test" and "positive test" are more of a concept than a strict activity. In both instances we are dealing with an input, an action, and an output. The action acts upon the input to derive a certain output. Both test cases can produce errors and, in fact, some say that the success of a test case is based upon the probability of it finding new errors in an application. positive testing is that testing which attempts to show that a given module of an application does what it is supposed to do.
Negative testing is that testing which attempts to show that the module does not do anything that it is not supposed to do.

in XigniteMetals web-service, we want to test that invalid information is handled correctly. for an instance, sending an invalid date, should fail the service and notify the service consumer, by not doing so, we have a problem. The first thing that comes up in our mind is senf invalid currency type and/or invalid metal symbol. as soon as you call the service using an invalid metal symbol or/andnot supported ciurrency you'll get the following exception.

The toolkit WSE 3.0 raise the exception because the first two parameters are strictly defined by the service, and not handeled by the service provider. the only value we can "play" with is the AsOfDate field. we are going to use a single checkpoint as the following :

Negative Test
Negative Testing - checked values

The expected messages ( results ) must not be tested accurately, but approximately enough, using a regular expression.

WS Negative Test Download
  • File Name: xignite3.zip
  • File Size: 48.0KB
  • File Version: 1.0
Click here to download ws negative test for QTP 10