Testing web services is similar to testing API. Basically, all we need is a framework that:

  1. Calls the web services
  2. Checks the response
  3. Asset the value returned accordingly

The framework we choose is dependent on the framework of the web service itself, for example, if the web service is written in Java, we would want to use Java to test, if its written in .NET, we would use C# to test, etc.

In the example above, we:

  • Create a class extending WebClient

public class ExtendWebClient : WebClient

  • ¬†Create a variable of class ExtendWebClient with overridden timeout

var client=new ExtendedClient(_TIMEOUT)

  • Set the header of the request

client.Headers.Add(HttpRequestHeader.ContentType,”text/xml”)

  • Set the XML data to be sent as string request

string request =”your XML here”

  • Calls the web service by passing the web services URL and XML (string)

¬†client.UploadString(new Uri(String.Format(“{0}/ADAuthenticate/ADAuthenticate.asmx”, _WEBSERVICEBASEURL)), request);

  • Web client will automatically return a success code (500) and error code otherwise