ParseRequest Method

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

The WebServiceInfo.ParseRequest method parses a SOAP request to be sent to a web service method and returns an object that contains input parameters for this method. Using the properties of the returned object, you can modify values that will be used in the method call.

Declaration

WebServiceInfoObj.ParseRequest(MethodNameRequestXml)

WebServiceInfoObj An expression, variable or parameter that specifies a reference to a WebServiceInfo object
MethodName [in]    Required    String    
RequestXml [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.

RequestXml

An object that holds the contents of a SOAP request. Since SOAP uses XML and the contents of SOAP requests matches the Document Object Model (DOM), the RequestXml 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 ParseRequest method creates and returns an object that holds data to be passed to the specified web service method. This object contains properties whose names coincide with the names of the method’s input parameters.

Remarks

You can also create an object holding input parameters for a web service method using the PrepareRequestObject method. The difference is that the properties of an object returned by the ParseRequest method hold values specified in the SOAP request, whereas the PrepareRequestObject method returns an object whose properties are not initialized.

To generate the new contents of a SOAP request for a web service method, use the PrepareRequest method.

Example

The following code obtains the last request sent to the tested web service, parses and modifies it, then it uses the modified request to create a new request to be sent to the web service.

JavaScript, JScript

function WebServiceRequestDemo()
{

  var WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService");
  // Specifies the method to which the request will be sent
  method = "SetSampleObject";

  

  // Obtains the last SOAP request sent to the tested web service
  LastRequest = WebServices.SampleWebService.LastRequest;

  // Parses the request content
  Request = WebServiceInfo.ParseRequest(method, LastRequest);
  // Obtains the object containing input parameters for the method
  NewObject = Request.obj;

  // Modifies the values to be used to call the method
  NewObject.Name = "Modified sample object";
  NewObject.X = 0.4;
  NewObject.Y = 0.6;

  // Generates a new SOAP request to be sent to the specified method
  NewRequest = WebServiceInfo.PrepareRequest(method, Request);

  

}

Python

def WebServiceRequestDemo():
  # Obtains the WebServiceInfo object 
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  # Specifies the method to which the request will be sent 
  method = "SetSampleObject"
  # ...
  # Obtains the last SOAP request sent to the tested web service 
  LastRequest = WebServices.SampleWebService.LastRequest
  # Parses the request content 
  Request = WebServiceInfo.ParseRequest(method, LastRequest)
  # Obtains the object containing input parameters for the method 
  NewObject = Request.obj
  # Modifies the values to be used to call the method 
  NewObject.Name = "Modified sample object"
  NewObject.X = 0.4
  NewObject.Y = 0.6
  # Generates a new SOAP request to be sent to the specified method 
  NewRequest = WebServiceInfo.PrepareRequest(method, Request)
  # ...

VBScript

Sub WebServiceRequestDemo

  Dim WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest

  ' Obtains the WebServiceInfo object
  Set WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  ' Specifies the method to which the request will be sent
  method = "SetSampleObject"

  

  ' Obtains the last SOAP request sent to the tested web service
  Set LastRequest = WebServices.SampleWebService.LastRequest

  ' Parses the request content
  Set Request = WebServiceInfo.ParseRequest(method, LastRequest)
  ' Obtains the object containing input parameters for the method
  Set NewObject = Request.obj

  ' Modifies the values to be used to call the method
  NewObject.Name = "Modified sample object"
  NewObject.X = 0.4
  NewObject.Y = 0.6

  ' Generates a new SOAP request to be sent to the specified method
  Set NewRequest = WebServiceInfo.PrepareRequest(method, Request)

  

End Sub

DelphiScript

procedure WebServiceRequestDemo();
var WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest;

begin

  // Obtains the WebServiceInfo object
  WebServiceInfo := WebServices.CreateWebServiceInfoFromItem('SampleWebService');
  // Specifies the method to which the request will be sent
  method := 'SetSampleObject';

  

  // Obtains the last SOAP request sent to the tested web service
  LastRequest := WebServices.SampleWebService.LastRequest;

  // Parses the request content
  Request := WebServiceInfo.ParseRequest(method, LastRequest);
  // Obtains the object containing input parameters for the method
  NewObject := Request.obj;

  // Modifies the values to be used to call the method
  NewObject.Name := 'Modified sample object';
  NewObject.X := 0.4;
  NewObject.Y := 0.6;

  // Generates a new SOAP request to be sent to the specified method
  NewRequest := WebServiceInfo.PrepareRequest(method, Request);

  

end;

C++Script, C#Script

function WebServiceRequestDemo()
{

  var WebServiceInfo, method, LastRequest, Request, NewObject, NewRequest;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices["CreateWebServiceInfoFromItem"]("SampleWebService");
  // Specifies the method to which the request will be sent
  method = "SetSampleObject";

  

  // Obtains the last SOAP request sent to the tested web service
  LastRequest = WebServices["SampleWebService"]["LastRequest"];

  // Parses the request content
  Request = WebServiceInfo["ParseRequest"](method, LastRequest);
  // Obtains the object containing input parameters for the method
  NewObject = Request["obj"];

  // Modifies the values to be used to call the method
  NewObject["Name"] = "Modified sample object";
  NewObject["X"] = 0.4;
  NewObject["Y"] = 0.6;

  // Generates a new SOAP request to be sent to the specified method
  NewRequest = WebServiceInfo["PrepareRequest"](method, Request);

  

}

See Also

TypeFactory Property
ParseResponse Method
PrepareRequest Method
PrepareRequestObject Method
Testing Web Services

Highlight search results