Tuesday, September 5, 2017

Web Service Test with Visual Studio



Microsoft Visual Studio : Web Service Test

 1)      in visual Studio, create a new project: 

2)      In the Solution Explorer window, add a new web performance test

Once you click the Web Performance test, the browser automatically pops up, it begins to record. You just , Click the stop button to stop recording. It Doesn’t record anything. 
  

3)      In the Web Performance Test Editor, right-click the Web performance test and select Add Web Service Request.

After Add Web Service Request. You should see the following in the visual studio. 
 

If you cannot see the right Properties window in the right part  in the Web Performance Test Editor, right click to open the Properties window:



4)      In the Properties window, make sure the Url is the name of webservice link: http://webserviceExample.com:9010/mywebservice.asmx


5)      Open a browser and type the URL of the webservice .asmx page in the Address toolbar. Select the method that you want to test and examine the SOAP message. It contains a SOAPAction.



6)      in the visual studio Web Performance Test Editor, right click to add Header to add a new header. In the Name property, type SOAPAction. In the Value property, type the value that you see in SOAPAction, such as " http://mywebservice/CheckStatus".





After add the header and assigned the values , it should looks like this:



7)      in the Web Performance Test Editor, right click to add URL QueryString Parameters



8)      Now back to the browser with the URL of the webservice .asmx page in the Address toolbar, you can see after “?” mark, there are ‘op=CheckStatus’.



9)      Now in the Web Performance Test Editor put the ‘op=CheckStatus’ in to the QueryString Parameters. 



        10) In the String Body part, now it is blank.



11)   Click the ellipsis (…) in the String Body property to open the body string editor popup window.





We copy the web service XML content resembles the following example into the String Boday part:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckStatus xmlns="http://tempuri.org/">
<userName>string</userName>
<password>string</password>
<orderID>int</orderID>
</CheckStatus>
</soap:Body>
</soap:Envelope>

You must replace any placeholder values in the XML with valid values for the test to pass. In the previous sample you would replace the two instances of string and one int. This Web service operation will only complete if there is a registered user who has placed an order.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckStatus xmlns="http://tempuri.org/">
<userName>tester</userName>
<password>test1234</password>
<orderID>100</orderID>
</CheckStatus>
</soap:Body>
</soap:Envelope>




Now you are ready to run the web service call test.





Reference link:
Create a web service call test:

No comments:

Post a Comment