How to create a web service load test using Visual Studio 2010? - web-services

Is there a way to test a Web Service using VS2010 like it's used to test a web site?
For a web site I can create a set of WebTestRequest objects that emulate the loading and the parsing of a web page from the test and then, implementing the GetRequestEnumerator I can yield results to the load test so that the execution time and payload of any single page could be evaluated by the test runner and published in my test run reports.
I would like to do the same for a test using web service call so that each time I call the web service (there is some logic in calling it, like logging in, getting a security token and pass a proper formatted XML document to the web service method) I can yield the result to my test runner and evaluate it.
Is there a way to do it or do I need to implement a specific class inheriting from the WebTestItem abstract class?
Regards
Massimo

Yes, it is possible to test Web Services using Web Performance Tests in Visual Studio 2010 Ultimate.
Here's a couple of useful links:
How to: Create a Web Service test (MSDN)
How to: Web Service Load Testing Using VSTS 2010 (Blog)
As a starting point, you can use a web proxy tool like Fiddler to intercept the HTTP requests made to the Web Services, copy the contents of the SOAP envelopes in the Web Performance Tests and then tweak them accordingly based on the test scenario you want to simulate.

This doesn't quite answer your question as it's a 3rd party tool, but SOAP UI is a great piece of (free) software for load testing web services, whether your own or someone else's. You can run individual requests, or do a bunch of different load tests.
We've used it for one service that uses credentials, so I'm sure it will work fine for your scenario.

Related

Can a web service client with identical signature call a different web service?

My project has gotten into web services lately, but our QA team has a request to be able to set up a clone client and clone web service so that they can issue a request from the clone client to the real web service and from the real client to the clone service to test the real pieces individually.
The clone client to real web service part is easy, I just wrap the generated client in a main() app that picks up data to send that the test team specifies. But the service part is confusing to me. How can I make a dummy service that just echoes out its requests to a log without affecting the real service? I want the real client to use the same generated client code, just point the soft-coded URL to the URL of the dummy.
If I define a new web service with identical names and signatures to the real service, can the real client hit the dummy with just a URL change? Or is it more complicated? Am I barking up the wrong tree?
Re: Making a dummy service
This would actually be called making a "mock" service or a web service "stub". You don't even technically have to code it - you can use tools. For example, SoapUI has the ability to import a WSDL and create a mock service. The have some other discussion of mock services as well - they can be used both to test the client application (or to simply develop it before the back-end resources are ready or available). To use a WSDL-based service stub you would simply change the endpoint of your client-under-test to the stub instance. SoapUI will show you (and let you configure) the stub's endpoint URL.
The trendy term for service mocking and stubbing is "service virtualization" (not to be confused with server virtualization as in virtual machines). Searches using this terminology will find you even more powerful (and expensive) tooling.
Re: Just a URL Change
Yep, for the most part. So long as the XML namespaces are the same and the WSDL is the same (minus endpoint URL) you should be fine. Since the WSDL acts as an interface contract, the stub MUST accept those same inputs and produce those same outputs. How it does so, of course, is up to you.
PS - free extra advice - Don't code a dummy client. Use tools (I'll use SoapUI again as an example free tool) to make your web service testing more robust and repeatable. You can create test suites with sample SOAP requests, add assertions on how the service should behave, and best of all - your investment in time of creating a test project can be shared across team members, cutting down time to test setup and making sure testing is thorough and repeatable. If you code a client, every tester/user of the test client will have their own way of testing, response inspection will probably be manual, and you'll notice when your best QA tester goes on vacation because regressions slip into the web service product. Repeatable testing can nix this, and tool based automated functional testing is the bees knees. You're already on the right path by testing the pieces individually.

Web service load test test using visual studio 2010

How to write custom web service load test:
All my web services has byte[] (byte array) as input and output.
Internally we have xml as input and ouuput which we encrypt and decrypt in custom way.
I checked that I can write down the custom validatation rule using visual studio. But can i also customize the input. (i.e. I pick the input load data from csv/xml and perform the required encrypt/decript before sending the the server)
Does the web service load testing supports the https communication?
Thanks and Regards,
Hardik
First, you have to create the Web Performance Test that will be used by the Load Test. Check these walkthroughs which will help you to find out:
How to change the code of a recorded Web Performance Test
How to data bind a Web Performance Test
How to add validation rules to a Web Performance Test
Also I believe that this guide will be very helpful to troubleshoot any possible issue
As far as I know there is no restriction on tesing HTTPS services through a Web Performance Test
*I suggest to check the option of Unit Test as well. I have tried it and in my opinion they are more easy to create them. Of course, this is your choice.

Web Services Testing

I know this question was asked million times but I'm gonna ask it again. I've been researching how to test web services for a while and I can't believe that there's pretty much one tool out there: SOAP UI. The other option that you have is creating web services stubs and writing unit tests per each ws stub.
I can't believe that Microsoft didn't come up with a solid solution for web services testing. So I guess my question: is SOAP UI the only tool for testing multiple web services?
P.S.
I'm also looking for something to integrate with TFS (I know SOAP UI can be integrated with msbuild)
Thanks
There are always options! Here an old article that could help out includes soapUI, Push to test and WebInject.
Looking to shell out dough? You could always use HP Service Test
Which do I use? soapUI of course :) Frankly, it's the most commonly used for a reason.
My alternative to soapUI is HP Service Test.
If I have to build a testing team with testers that are not exposed to web services and SOA in general, then the learning curve and team ramp time associated with HP Service Test is short essentially because of the Canvas based visual drag and drop designer that Service Test boasts.
Perhaps, everything you could do with HP Service Test 11.20 is possible with SOAP UI 4. They both do have striking inherent features that is kind of mutually exclusive between these two.
If your organization already uses HP's Quality Center, QTP and Load Runner, then for easy effortless mangement of all test cases in your app's boundary it is preferred to have HP Service Test because it integrates with all the aforementioned products.
With Service Test, I personally like the Canvas designer in HP Service Test and the ability to call .Net assemblies inside of Service Test is just a boon as I am a .Net developer. And the ToolBox has a list of controls that every tester/dveloper needs. And it is just efforless to built a hi-fi test case with Service Test. It is worth the money.
With soapUI, I like the HTTP Recording (works much like Fiddler) and the Security check options (to name a few, XSLT injection, XSS checks).
soapUI is omnipresent.
TFS integration, I am not there yet.

Selenium - can it test a B2B web service

I've used Selenium to do lots of UI testing from the browser. If you have a web service behind the Java jsp page i.e. in a servlet, you can test it from Selenium.
Can Selenium be used to test a B2B web service i.e. a web service called from a backend that has no browser UI component?
I have used SOAPUI to do this kind of testing in the past but our test department is trying to standardise on Selenium.
You can but I would not recommend it. If the page is returning XML, you won't be able to use the standard Selenium calls to verify what is happening as you won't have access to the DOM. If its returning plain text for JavaScript then you will struggle with verifying the output.
This is a definite case of using the right tool for the job and Selenium is not the right tool for testing web services. I would use soapUI or just use some http library to call the service URL and then verify the results.
If they are looking to standardise they need to standardise tools for their purpose. Selenium for UI, soapUI for webservices,XUnit Framework for unit and integration.
You can, but it's really not the right tool for the job. It's like trying to hammer a nail into a piece of wood using a stapler instead of a hammer.
That said, probably the most appropriate way to create a page with all your input parameters which could do the call for you and echo the results back into a html element. If the service is meant for AJAX calls then this is probably the ideal solution for your service.
The correct approach would be to use a unit testing framework and create a test harness which you can push your parameters into, execute the service call and retrieve the results in a meaningful way for assertion.

Building web services without a web server

OK, this is impossible, but I will try to explain the situation here.
Let's say we have cases, that we need a fast setup of a web server in order to have a simple soap web service running (querying a db and so on).
In VS though, upon debugging a web project, it creates a quick ASP.NET development server without relying on the actuall IIS that might be installed on the PC.
Is there any project that does something like that?
This would be ideal for small projects, where a simple executable would get a server ready to go and would allow web services to be executed right away.
I have looked at some stuff over the net like http://msdn.microsoft.com/en-us/magazine/cc163879.aspx and http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2004/05/24/4479.aspx but they seem to be quite outdated and i am not sure how well they work (havent tested them thoroughly)
EDIT: I have build an application like the one you suggest. However, how can i implement HTTP GET/POST requests to the service using this method? I tried using WebGet after my operationcontract but it didnt work. For example, my service is at http://localhost:8080/Service and i would like to use it such as http://localhost:8080/Service/getMethod?x=2.
I believe that the development server used by Visual Studio is based off of the Cassini code base (of which there is a fork here). I also found this article on hosting the asp.net runtime. It was also created a while back (2004), but has been updated since (2008). I think a lot of the core concepts are probably still the same.
Another approach would be a roll-your-own web server using the HttpListener class. This could take some work if you want to use it for hosting asmx type services, but if you were doing RESTful services, it isn't too bad of an option (this is actually how RavenDB works if you are not hosting it under IIS).
A WCF service can be hosted in almost any kind of application, including a Windows Service or a console application. There is no need for a web server at all.
Alright,
i've done it so im posting it here to help anyone who has issues with similar problems.
Create your WCF Service file as usual and then by using ServiceHost (or WebServiceHost) you can easily create a WCF service.
In order to use GET http requests to make it simple to communicate with mobile devices (such as iphone) you can use WebGet above your service methods and make sure you manually add a service endpoint using WebHttpBinding for WebServiceHost or WebHttpBinding with an WebHttpBehavior for ServiceHost.
Then you can call your service methods such as http://localhost:port/webhttpendpointaddress/mymethod?x=2.