Results 1 to 2 of 2
  1. #1

    Web Service Validation/Verification

    Hello everyone,
    I am looking for a way to efficiently verify the results of a very very complex object returned from a web service call.

    I need to validate this service call results against the database that actually contains the data.

    I dread having to figure out the queries needed to obtain the data from the database to compare against the web service results. Has anyone else been given the challenge of validating/testing web services?

    Build the client to call the service is not a problem, however, validating the data returned from the service call is starting to be a little overwhelming for me.

    does anyone have any good ideas as to how to go about validation? [img]/images/graemlins/confused.gif[/img]

  2. #2

    Re: Web Service Validation/Verification

    Hi pebranch,

    I recommend that you use a "Web Service" checkpoint to accomplish your task (see the "Web Service Checkpoints" help topic for details).
    After creating the checkpoint, you can use the following script to validate data from the web service response:

    <font class="small">Code:</font><hr /><pre>// JScript

    // Please change the following values:
    // &lt;WEB_SERVICE&gt; = the element of the WebServices project item that you use
    // &lt;WEB_SERVICE_METHOD&gt; = the method of the &lt;WEB_SERVICE&gt; object you need to call
    // &lt;WEB_SERVICE_METHOD_PARAMETERS&gt; = parameters of the &lt;WEB_SERVICE_METHOD&gt; method
    // &lt;WEB_SERVICE_METHOD_XML_RESULT&gt; = the XML file in the Stores.XML collection containing the response from your web service.

    // Sets the correct value
    function SetCorrectValue(expectedResult)
    var xmlDocument = XML.&lt;WEB_SERVICE_METHOD_XML_RESULT&gt;.Document ;
    xmlDocument.setProperty("SelectionNamespaces", 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://tempuri.org/"');
    var resultNodes = XML.&lt;WEB_SERVICE_METHOD_XML_RESULT&gt;.Document .selectNodes("//ns1:" + &lt;WEB_SERVICE_METHOD&gt; + "Result");

    // Throws an error if multiple results are found
    if (1 != resultNodes.length) {
    Log.Error("Cannot work with multiple results");
    return false;

    // Specifies a new value of the stored response
    var resultNode = resultNodes.item(0);
    resultNode.childNodes.item(0).data = expectedResult;

    return true;

    function Main ()
    // The expected result
    var expectedResult = "&lt;CORRECT_VALUE&gt;";

    if (!SetCorrectValue(expectedResult)) {
    Log.Error("An error occurred when running the SetCorrectValue method");

    if(!XML.&lt;WEB_SERVICE_METHOD_XML_RESULT&gt;.Comp are(WebServices.&lt;WEB_SERVICE&gt) {
    Log.Error("Values are not identical");
    </pre><hr />
    Alex - SmartBear Support



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:26 PM.

Copyright BetaSoft Inc.