ParseResponse Method

Applies to TestComplete 12.60, last modified on September 17, 2018

Description

The WebServiceInfo.ParseResponse method parses a SOAP response received from a web service method and returns an object that contains output parameters from the web service method (that is, the method’s return data). You can use the properties of the returned object to check the method’s actual output data with the expected data.

Declaration

WebServiceInfoObj.ParseResponse(MethodNameResponseXml)

WebServiceInfoObj An expression, variable or parameter that specifies a reference to a WebServiceInfo object
MethodName [in]    Required    String    
ResponseXml [in]    Required    An IXMLDOMDocument object    
Result Object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

MethodName

A string holding the name of a web service method.

ResponseXml

An object that holds the contents of a SOAP response. Since SOAP uses XML and the contents of SOAP responses matches the Document Object Model (DOM), the ResponseXml parameter should specify an object implementing the IXMLDOMDocument interface.

For more information on the IXMLDOMDocument interface and DOM, see the XML Core Services and Document Object Model article in the MSDN Library.

Result Value

The ParseResponse method creates and returns an object that holds data returned by the specified web service method. This object contains properties whose names coincide with the names of the method’s output parameters.

Example

The following code obtains the last web service response, parses it and obtains the object that holds the data returned by the specified web service method. Then it posts the returned data to the log.

JavaScript, JScript

function WebServiceResponseDemo()
{

  var WebServiceInfo, method, Str, LastResponse, Response;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService");
  // Specifies the method whose response will be obtained
  method = "SetSampleObject";

  

  // Obtains the last web service response
  LastResponse = WebServices.SampleWebService.LastResponse;

  // Parses the response content
  Response = WebServiceInfo.ParseResponse(method, LastResponse);
  // Posts the data returned by the web service method to the log
  Log.Message(Response.SetSampleObjectResult);

  

}

Python

def WebServiceResponseDemo():
  # Obtains the WebServiceInfo object 
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  # Specifies the method whose response will be obtained 
  method = "SetSampleObject"
  # ...
  # Obtains the last web service response 
  LastResponse = WebServices.SampleWebService.LastResponse
  # Parses the response content 
  Response = WebServiceInfo.ParseResponse(method, LastResponse)
  # Posts the data returned by the web service method to the log 
  Log.Message(Response.SetSampleObjectResult)
  # ...

VBScript

Sub WebServiceResponseDemo

  Dim WebServiceInfo, method, Str, LastResponse, Response

  ' Obtains the WebServiceInfo object
  Set WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  ' Specifies the method whose response will be obtained
  method = "SetSampleObject"

  

  ' Obtains the last web service response
  Set LastResponse = WebServices.SampleWebService.LastResponse

  ' Parses the response content
  Set Response = WebServiceInfo.ParseResponse(method, LastResponse)
  ' Posts the data returned by the web service method to the log
  Log.Message(Response.SetSampleObjectResult)

  

End Sub

DelphiScript

procedure WebServiceResponseDemo();
var WebServiceInfo, method, Str, LastResponse, Response;

begin

  // Obtains the WebServiceInfo object
  WebServiceInfo := WebServices.CreateWebServiceInfoFromItem('SampleWebService');
  // Specifies the method whose response will be obtained
  method := 'SetSampleObject';

  

  // Obtains the last web service response
  LastResponse := WebServices.SampleWebService.LastResponse;

  // Parses the response content
  Response := WebServiceInfo.ParseResponse(method, LastResponse);
  // Posts the data returned by the web service method to the log
  Log.Message(Response.SetSampleObjectResult);

  

end;

C++Script, C#Script

function WebServiceResponseDemo()
{

  var WebServiceInfo, method, Str, LastResponse, Response;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices["CreateWebServiceInfoFromItem"]("SampleWebService");
  // Specifies the method whose response will be obtained
  method = "SetSampleObject";

  

  // Obtains the last web service response
  LastResponse = WebServices["SampleWebService"]["LastResponse"];

  // Parses the response content
  Response = WebServiceInfo["ParseResponse"](method, LastResponse);
  // Posts the data returned by the web service method to the log
  Log["Message"](Response["SetSampleObjectResult"]);

  

}

See Also

TypeFactory Property
ParseRequest Method
PrepareRequest Method
PrepareRequestObject Method
Testing Web Services

Highlight search results