Highlighted
Absent Member.. Absent Member..
Absent Member..
1230 views

Posting XML files and validating response

Hi I am fairly new to the loadrunner scripting and would like some help.

 

I need to POST some xml files which I am attempting as follow:

 

lr_start_transaction("BDD_trajectories");


 web_custom_request("BDD_cruise",
   "URL=http://{URL_Param}",
   "Method=POST",
   "TargetFrame=",
   "Resource=0",
   "Referer=",
   "Mode=HTTP",
   //"Body=lr_eval_string(lr_eval_string({xmlFiles}))",
   "Body=lr_eval_string({xmlFiles})",
    LAST); 


 lr_end_transaction("BDD_trajectories", LR_AUTO);
 

 

the {xmlFiles} is path to the xml files and the {URL_Param} is the server that takes a set of trajectory values from these xml file and sends it to another server (external to our ogranisation) which in turn returns as set of CSV values for the requested parameters, here some smaple input and expected output.

 

INPUT:

 

 <wps:Data>
                <wps:ComplexData mimeType="text/csv">lat,lon,height,time
48.7537222222,2.10236111111,500,2015-08-11T06:00:49Z
            </wps:ComplexData>

 

OUTPUT:

 

Relative humidity (N_PERC),Temperature (T_KELV),Wind - u component (S_MPS),Wind - v component (S_MPS)
82.92,290.98,-1.54,-2.51

 

I would like to be able to log/validate the CSV values any help would be appreciated. I have enabled the "Data returned by server" option in the Runtime settings>Log section but can not see in the ouput the CSV values!

 

thanks

 

 

0 Likes
3 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: Posting XML files and validating response

Hi,

 

Have you tried "lr_xml_extract" or "lr_xml_get_values" function to validate the response?

Regards,
Gagandeep Malviya

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Posting XML files and validating response

Thank Gagandeep

I was not sure if my XML request is being actuall passed and parssed error free to the server so I added an error before the call like this:

 

web_add_header("Content-Type", "text/xml; charset=utf-8");
lr_start_transaction("BDD_trajectories");


 web_custom_request("BDD_cruise",
   "URL=http://{URL_Param}",
   "Method=POST",
   "TargetFrame=",
   "Resource=0",
   "Referer=",
   "Mode=HTTP",
   "Body={xmlLine}",
    LAST); 

 

and also parametrised the XML as a one line string {xmlLine} but when I run the script now at the bottome of the Server response body log I get the following error:

 

<?xml version="1.0" encoding="UTF-8"?>\n
Action.c(19): <ServiceExceptionReport version="1.3.0">\n
Action.c(19): <ServiceException code="InvalidFormat">Failed to parse XML POST request: stream:Extra co
Action.c(19): ntent at the end of the document\n
Action.c(19): : %31</ServiceException>\n
Action.c(19): </ServiceExceptionReport>\n

 

 

here is my xml input file

 

 

<?xml version="1.0" encoding="UTF-8"?>\n
Action.c(19): <ServiceExceptionReport version="1.3.0">\n
Action.c(19): <ServiceException code="InvalidFormat">Failed to parse XML POST request: stream:Extra co
Action.c(19): ntent at the end of the document\n
Action.c(19): : %31</ServiceException>\n
Action.c(19): </ServiceExceptionReport>\n

 

it seems as if there is something wrong in the input xml file but I can't find what?! here is my xml input

 

<wps:Execute xmlns:wps="http://www.opengis.net/wps/1.0.0"
version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
<ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">multi_point</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">model</ows:Identifier>
<wps:Data>
<wps:LiteralData>GL17EGRR</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">parameters</ows:Identifier>
<wps:Data>
<wps:LiteralData>Relative humidity,Temperature,Wind - u component,Wind - v component</wps:LiteralData> </wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">points</ows:Identifier>
<wps:Data>
<wps:ComplexData mimeType="text/csv">lat,lon,height,time
48.7537222222,2.10236111111,500,2015-08-11T06:00:49Z
</wps:ComplexData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput>
<ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">result</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Posting XML files and validating response

Could you please check whether there is any extra space in input XML?

 

Also, can you try using webservice protocol instaed of using custom request, I would suggest this option so that XML should go in proper format. and you can get/capture response using "lr_xml_extract" or "lr_xml_get_values" function.

Regards,
Gagandeep Malviya

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.