The LoadRunner Blog

Tuesday, November 07, 2006

XML Custom Requests - and Responses

Okay, if you are 'testing' XML pages rather than the regular HTTP pages - you can use lr_xml_find to text-check your responses. Recently I was required to code a test that sends an XML File to a service and gets a return XML file. The following is the code that works. You can program many variants of XML tests. Refer to Pages 1115-1128 of the VUGen guide "Programming with the XML API" for further details


The Code:


Action()
{
//Save XML Data into Character Variable
char *xml_input=
""
"WEB"
"100"
"1234567"
""
"VTEST"
"USD"
"4111123456789022"
"123"
"2012"
""
""
"8"
"9"
"2006"
"";

//Move Character Variable value into Parameter for LR
lr_save_string(xml_input,"XML_Input_Param");

//Capture all XML Data using WebRegSaveParam
web_reg_save_param("ServerXML", "LB=", "RB=", "Search=body", LAST);


/*Send Custom Request - using XML from XML_Input_Param in which char variable data has been saved */
web_custom_request("SendXML",
"URL=https://10.10.xxx.xxx:8080/authService",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTTP",
"Body={XML_Input_Param}",
LAST);

//Converted XPath verifications
lr_xml_find("XML={ServerXML}",
"Query=/CCAuthResponse/responseCode",
"Value=1",
LAST );
return 0;
}

7 Comments:

Post a Comment

<< Home