Example: web_service_callWeb Services Functions (SOAP, WEB_SERVICE, Silverlight)

Calls a web service.

int web_service_call( const char *StepName, [URL,] ExpectedResponse, <List of specifications>, [BEGIN_ARGUMENTS, Arguments, END_ARGUMENTS,] [Send Attachments, ][BEGIN_RESULT, Results, END_RESULT,] [Receive Attachments, ] LAST );
StepName The name of the step, as it appears in the test tree. Any text can be used.
ExpectedResponse The type of response to accept. See Expected Response.
URL The URL (Uniform Resource Locator) of the web service to load.
List of specifications A comma separated list of the format "Specification=value". For a list, see Specifications.
BEGIN_ARGUMENTS A marker that indicates the beginning of the ARGUMENTS section.
ArgumentsArgumentName=Value. Either the argument name as specified in the WSDL and its assigned value, or one of the User Handler Arguments.
END_ARGUMENTS A marker that indicates the end of the ARGUMENTS section.
Send Attachments The attachments to send. For details, see Attachment Specifications.
BEGIN_RESULT A marker that indicates the beginning of the RESULT section.
ResultsResultName=ParamName. The name of result argument or return value as specified in the WSDL, and the name of parameter in which to store the result.
END_RESULT A marker that indicates the end of the RESULT section.
Receive Attachments The expected attachments to save when received. For details, see Attachment Specifications.
LAST A marker that indicates the end of the arguments list.

The web_service_call function calls a web service.

This function is generated when you use the Import WSDL wizard in Web Service Vusers. When you import a WSDL document, by default a web_service_call function is generated.

This is a high-level function that lets you modify all the SOAP arguments intuitively. Because editing the arguments is likely to be error-prone, it is recommended that the function be modified in the tree view rather than in the script editor.

By default, the URL end-point is taken from the WSDL file. Use the URL argument to overwrite (or parameterize) the Web Service end-point.

If you import a web service using the .NET toolkit you may need a web_service_set_option call before the web_service_call in these cases.:

  • If the SOAP request message includes WS-Addressing and the WS-Addressing is not required, invoke web_service_set_option("ExcludeWseHeaders", true) before the web_service_call.
  • If the SOAP response body is in MIME format, invoke web_service_set_option("HandleMIMEResponse", true) before the web_service_call.
  • If the response does not match the ExpectedResponse argument because the server adds security tokens, invoke web_service_set_option("DoNotValidateSecurity", true) before the web_service_call.

Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure. Note that in many cases, this return value indicates the technical success of the function, and not the result. For example, a function that registers a string to be found in a subsequent step returns LR_PASS to indicate that the registration was successful. This does not indicate that the string was found in the server response.


The URL argument can be parameterized. Most of the values of the specifications can be parameterized. Exceptions are noted in the descriptions below.