2. SOAPSonar – Starting with SOAP and REST

So you have installed SOAPSonar and it’s registered as is detailed in this earlier tutorial. Were now do you start? First let me explain how SOAPSonar works. SOAPSonar is device independent, and requires no client or client application in order to test the Web Services API. It sends requests directly to the Web Services API, and receives the response.

SOAPSonar Test Cycle

The SOAPSonar Interface is divided at the top into 3 Views. Project View, Run View and Report View. In Project View we create the individual test cases, defining data source, variables and success criteria. In Run View we combine these test cases into automated test scenarios, by dragging or linking the independent test cases created.We can also define virtual agents, for load testing and logging option. In Report view we see the results of the independent test cases that are run, compared against the success criteria we established. The logs provide addition detail on for further trouble shooting errors. On the right is 4 modes to run the tests in.

SOAPSonar headingsQA Mode, Performance, Compliance and Vulnerability. SOAPSonar uses the same test cases created in Project View, and Test Scenarios in Run View, to run in any of these modes, yet provides different reports.

A SOAP Based API

SOAP Web Services API, provide a WSDL, which can be captured by SOAPSonar and used to automatically generate a UI. For example if you put http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx into your browser, you will see a free basic SOAP service example for calculation.

If thiis service seems to be down try http://www.w3schools.com/webservices/tempconvert.asmx?wsdl

1. Make sure you are in project view and QA mode. Place that same link into SOAPSonar’s Capture WSDL bar and add ?wsdl afterwards or paste http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?wsdl Then select Capture WSDL or press enter, you can automatically import the available services. If you look on the left, in the project Tree, you will now see a service called Calculator.asmx which has 4 services, Add, Subtract, Multiply and Divide.

Capture SOAP WSDL

2. If you select Documents you can view the WSDL and Embedded Schema.

View Schema

3. Now lets see the automatic UI for the Add service. Select Add_1 service. In the main section, there is a Request section on top, and under that a Response section. Lets start simple and enter a= 2 and b= 2 then the green check mark to commit the test settings and the blue arrow to send current request to server. If you look at the Response section, you should see the result is 4.

send test

4. If you select the XML tab at underneath the Request Section, you can view the XML Request that was sent. Changes in the Schema Fields or here are mirrored. Change the a field in the XML by changing the 2 to a 3 in <tns:a>3</tns:a> then then the green check mark to commit the test settings and the blue arrow to send current request to server. Does the response now read 5?

XML send

REST Based API

REST based API do not provide a WSDL that can be captured. Their lightweight nature, requiring a bit more knowledge or documentation.

1. To start a REST test, select File, New, Test Group. You should then get NewCustomGroup1 in the project Tree. If you right click in it you can rename it REST Demo.

New Rest Test

2. If you Select Tests, then right click and and select New REST Test, you will see a similar but slightly different Request and Response section.

3. Lets Check the Bitcoin price. In the URI in the rest section, paste https://btc-e.com/api/2/btc_usd/ticker and leave the method as GET. then the green check mark to commit the test settings and the blue arrow to send current request to server. What did you for a response? My high I got was US$584 today.

Bitcoin Request

4. Notice that by pasting in the URI, it is then broken down into Protocol, Host, and Path. Right click on the New Test_1 and rename it BTC_Bitcoin.

5. Please save your test plan at this point for the next Tutorial on Run View.

Conclusion

Well now that you have some idea how to start a REST or SOAP Test case development, take a few minutes to try a few additional service or services from your own environment. Try a BBC Music artist

http://www.bbc.co.uk/music/artists/ada7a83c-e3e1-40f1-93f9-3e73dbc9298a

or SOAP Soccer information service

http://www.xmlsoccer.com/FootballData.asmx?WSDL.

For that matter, Facebook, twitter and many other companies offer API’s that can be used, although some require a developer registration and key first. Perhaps you have a service you familiar with you would like to try?

We now have some idea of project view and how to start with a SOAPSonar project. next we will look at Run View and how to use some of these unit tests.

Comments and question below will help others learn.