Example: web_service_call

In the first example, the web_service_call function calls a Web service GetUKLocationByTown to locate a location on a map.

#include "as_web.h"

web_service_call( "StepName=UkLocation",
    "ExpectedResponse=AnySoap",
    "URL=http://www.locatorx.net/uklocation.asmx",
    "SOAPMethod=TownService|TownServiceSoap|GetUKLocationByTown",
    "SOAPMethodNamespace=http://www.locatorX.NET",
    "SOAPMethodStyle=document",
    "SOAPAction=http://www.locatorX.NET/GetUKLocationByTown",
    "WSDL=http://www.locatorx.net/uklocation.asmx?WSDL",
    "SOAPHeader=<SoapHeader><e>jb14</e></SoapHeader>",
    "Snapshot=t1.inf",
    BEGIN_ARGUMENTS,
        "Town=London",
    END_ARGUMENTS,
    BEGIN_RESULT,
         "GetUKLocationByTownResult=Result",
    END_RESULT,
    LAST );

In the second example, the web_service_call function performs DIME uploads and downloads.

lr_save_string("Some content for an attachment in a Parameter",
    "pAttachmentContent" ); // DIME encoded upload web_service_call( "StepName=DimeUploadFile_102",     "ExpectedResponse=AnySoap",     "SOAPMethod=MyDimeService|MyDimeServiceSoap|DimeUploadFile",     "SOAPHeader=<SoapHeader><e>jb14</e></SoapHeader>",     "WSDL=http://myServer/DimeGen/MyDimeService.asmx?WSDL",     "UseWSDLCopy=1",     "Snapshot=t1124018494.inf",     BEGIN_ARGUMENTS,     "file_name=d:\\temp\\myUploaded.txt",     END_ARGUMENTS,     ATTACHMENTS_FORMAT_DIME,     ATTACHMENT_ADD,
    "FiLeNaMe=d:/temp/attachment.in",//"ContentType=text/plain",     BEGIN_RESULT,     END_RESULT,     LAST ); // DIME encoded download web_service_call( "StepName=DimeDownloadFile_102", "SOAPMethod=MyDimeService|MyDimeServiceSoap|DimeDownloadFile",     "ExpectedResponse=AnySoap",     "WSDL=http://myServer/DimeGen/MyDimeService.asmx?WSDL",     "UseWSDLCopy=1",     "Snapshot=t1124022373.inf",     BEGIN_ARGUMENTS,     "file_name=d:\\temp\\myUploaded.txt",     END_ARGUMENTS,     BEGIN_RESULT,     END_RESULT,     ATTACHMENT_SAVE_ALL,     "pAraMnAmepReFiX=pAttachmentContent",     LAST );

In the third example, the server reply is directed to a host using WS-Addressing with as specified by the WSAReplyTo argument. In the first call, the WSAAction is specified. Both calls are asynchronous, as indicated by the AsyncEvent argument. The test run continues until the following web_service_wait_for_event invocation.

web_service_call( "StepName=echo_101",
    "ExpectedResponse=AnySoap",
    "SOAPMethod=MyService|MyServiceSOAP12port0|echo",
    "SOAPHeader=<SoapHeader><e>jb14</e></SoapHeader>",
    "ResponseParam=response",
    "Service=MyService",
    "Snapshot=t1156241380.inf",
    "WSAReplyTo=111.111.111.011",
    "WSAAction=http://example1.org/MyServiceSOAP12port0/echo",
    "AsyncEvent=event1",
    BEGIN_ARGUMENTS,
    "xml:part1=<part1><EchoInput>true</EchoInput><Latency>4</Latency></part1>",
    END_ARGUMENTS,
    BEGIN_RESULT,
    "part1/EchoOutput=Param_EchoOutput1",
    END_RESULT,
    LAST );

web_service_call( "StepName=echo_101",
    "SOAPMethod=MyService|MyServiceSOAP12port0|echo",
    "ResponseParam=response",
    "Service=MyService",
    "Snapshot=t1156241380.inf",
    "WSAReplyTo=111.111.111.011",
    "AsyncEvent=event2",
    BEGIN_ARGUMENTS,
"xml:part1=<part1><EchoInput>false</EchoInput><Latency>1</Latency></part1>",
    END_ARGUMENTS,
    BEGIN_RESULT,
    "part1/EchoOutput=Param_EchoOutput2",
    END_RESULT,
    LAST );

web_service_wait_for_event("Quantifier=ALL","Timeout=11111",BEGIN_EVENTS,"event1","event2",END_EVENTS,LAST );