TypeFactory Property

Applies to TestComplete 15.62, last modified on March 19, 2024
Testing web services with TestComplete is obsolete. We recommend that you use ReadyAPI, another SmartBear's automated testing tool for SOAP and REST web services.
If needed, you can run ReadyAPI tests from TestComplete.

Description

The TypeFactory property lets you create complex parameters for web services’ method calls.

Declaration

WebServiceInfoObj.TypeFactory

Read-Only Property Object
WebServiceInfoObj An expression, variable or parameter that specifies a reference to a WebServiceInfo object

Applies To

The property is applied to the following object:

Property Value

The object returned by the TypeFactory property holds properties whose names coincide with names of complex types defined in the web service’s WSDL document. Via the TypeFactory property, you can create complex parameters for web services’ method calls and specify their property values.

Example

The following example demonstrates how you can create a complex parameter for a web service method:

JavaScript, JScript

function WebServiceInfoTypeFactory()
{

  var WebServiceInfo, Obj;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService");
  // Creates a complex parameter of the WebService method
  Obj = WebServiceInfo.TypeFactory.SampleTestClass;

  // Modifies the object’s properties
  Obj.Name = "Complex Parameter";
  Obj.X = 15;
  Obj.Y = 15;

  // Calls the web service method and passes the object as the parameter
  WebServices.SampleWebService.SetSampleObject(Obj);

}

Python

def WebServiceInfoTypeFactory():
  # Obtains the WebServiceInfo object
  WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  # Creates a complex parameter of the WebService method
  Obj = WebServiceInfo.TypeFactory.SampleTestClass
  # Modifies the object's properties
  Obj.Name = "Complex Parameter"
  Obj.X = 15
  Obj.Y = 15
  # Calls the web service method and passes the object as the parameter
  WebServices.SampleWebService.SetSampleObject(Obj)

VBScript

Sub WebServiceInfoTypeFactory

  Dim WebServiceInfo, Obj

  ' Obtains the WebServiceInfo object
  Set WebServiceInfo = WebServices.CreateWebServiceInfoFromItem("SampleWebService")
  ' Creates a complex parameter of the WebService method
  Set Obj = WebServiceInfo.TypeFactory.SampleTestClass

  ' Modifies the object’s properties
  Obj.Name = "Complex Parameter"
  Obj.X = 15
  Obj.Y = 15

  ' Calls the web service method and passes the object as its parameter
  Call WebServices.SampleWebService.SetSampleObject(Obj)

End Sub

DelphiScript

procedure WebServiceInfoTypeFactory();
var WebServiceInfo, Obj;
begin

  // Obtains the WebServiceInfo object
  WebServiceInfo := WebServices.CreateWebServiceInfoFromItem('SampleWebService');
  // Creates a complex parameter of the WebService method
  Obj := WebServiceInfo.TypeFactory.SampleTestClass;

  // Modifies the object’s properties
  Obj.Name := 'Complex Parameter';
  Obj.X := 15;
  Obj.Y := 15;

  // Calls the web service method and passes the object as the parameter
  WebServices.SampleWebService.SetSampleObject(Obj);

end;

C++Script, C#Script

function WebServiceInfoTypeFactory()
{

  var WebServiceInfo, Obj;

  // Obtains the WebServiceInfo object
  WebServiceInfo = WebServices["CreateWebServiceInfoFromItem"]("SampleWebService");
  // Creates a complex parameter of the WebService method
  Obj = WebServiceInfo["TypeFactory"]["SampleTestClass"];

  // Modifies the object’s properties
  Obj["Name"] = "Complex Parameter";
  Obj["X"] = 15;
  Obj["Y"] = 15;

  // Calls the web service method and passes the object as the parameter
  WebServices["SampleWebService"]["SetSampleObject"](Obj);

}

See Also

ParseRequest Method
ParseResponse Method
PrepareRequest Method
PrepareRequestObject Method

Highlight search results