Highlighted
TRao Absent Member.
Absent Member.
3244 views

XML Response parsing

Hello Guys, Help me on this... I am testing 3 different SOAP web services in VUGen and my requirement is: One webservice output is input to the second web service and 2nd web service output is the input for the 3rd web service.

 

When I see 1st webservice response like below.

 

<soap: envelolp....>

  <body..>

    <return>

      <bankaccountnumber>123456</bankaccountnumber>

      <firstname>John Dhoe</firstname>

     <lastname>peter</lastname>

     <ssn>123456789</ssn>

   </return>

  </body..>

</soap:env....>

 

I need to capture contents in between <return> tags, but I don't want <return> tags in that. I tried with lr_xml_extract but I am getting with <return> tags.

 

How to get the contents in between the tags in VUGen.

Tags (1)
0 Likes
4 Replies
Dennis Honored Contributor.
Honored Contributor.

Re: XML Response parsing

Hi TRao,

 

Not exactly what you are looking for but you could extract the separate values.

 

To get the value of 'SSN' use this xpath:  "Query=/soap:Envelope/soap:Body/return/ssn/text()"

To get the value of 'firstname' use this xpath:  "Query=/soap:Envelope/soap:Body/return/firstname/text()"

This is the same as using  lr_xml_get_values with xpath  "Query=/soap:Envelope/soap:Body/return/ssn"

 

Maybe you could solve your 'problem' with this help 🙂

 

Good luck

 

NB: If this solves your problem / helps you on the way, consider acknowledging with Kudos. To kudo a post, select the thumbs up icon in the gray square by the post in the thread.
0 Likes
TRao Absent Member.
Absent Member.

Re: XML Response parsing in VUGen

Hi ,

 

Thanks for the response.  Basically my requirement in detail is:

1) Capture 1st web service call response within <return> tags.

<soap: envelolp..CheckClientInfo..>

  <body..>

    <return>

      <bankaccountnumber>123456</bankaccountnumber>

      <firstname>John Dhoe</firstname>

     <lastname>peter</lastname>

     <ssn>123456789</ssn>

   </return>

  </body..>

</soap:env....>

 

2) Call 2nd different web service with data captured from above as request.

<soap: envelolp..Authorize..>

  <body..>

    <arg01>

      <bankaccountnumber>123456</bankaccountnumber>

      <firstname>John Dhoe</firstname>

     <lastname>peter</lastname>

     <ssn>123456789</ssn>

   </arg01>

  </body..>

</soap:env....>

 

So if you observe from 1st ws call response capture data within <return> tags and insert that in between <arg01> tags in 2nd ws call.

 

Please advice.. and thanks in advance.

 

0 Likes
Dennis Honored Contributor.
Honored Contributor.

Re: XML Response parsing in VUGen

Two protocols:

- Web/Multimedia

- WebServices

 

 

If you are using Web/Multimedia protocol, create something like this:

 

Action()
{

 

// Save the response in the variable 'ResponseBody'

web_reg_save_param("ResponseBody",

"LB=",
"RB=",
"Search=Body",
"IgnoreRedirections=Yes",
LAST);

 

// Put your 1st web_custom_request here

.

.

.

 

// Store each value in a separate variable

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmBankAccountNumber", 
"Query=/soap:Envelope/soap:Body/return/bankaccountnumber", LAST);

 

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmFirstName", 
"Query=/soap:Envelope/soap:Body/return/firstname", LAST);

 

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmLastName", 
"Query=/soap:Envelope/soap:Body/return/lastname", LAST);

 

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmSSN", 
"Query=/soap:Envelope/soap:Body/return/ssn", LAST);

 

// Put your 2nd web_custom_request here

.

.

.

"<body..>"

" ... "
" <bankaccountnumber>{prmBankAccountNumber}</bankaccountnumber>"
" <firstname>{prmFirstName}</firstname>"
" <lastname>{prmLastName}</lastname>"
" <ssn>{prmSSN}</ssn>"
" ..."

.

.

.

 

 

return 0;
}

 

 

If you are using webservices protocol, create something like this:

 

Action()
{

 

// Put your 1st web_service_call here

// Save the response in the variable 'ResponseBody'

.

.

.

"ResponseParam=ResponseBody",

.

.

.

 

// Store each value in a separate variable

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmBankAccountNumber", 
"Query=/soap:Envelope/soap:Body/return/bankaccountnumber", LAST);

 

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmFirstName", 
"Query=/soap:Envelope/soap:Body/return/firstname", LAST);

 

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmLastName", 
"Query=/soap:Envelope/soap:Body/return/lastname", LAST);

 

lr_xml_get_values("XML={ResponseBody}", 
"ValueParam=prmSSN", 
"Query=/soap:Envelope/soap:Body/return/ssn", LAST);

 

// Put your 2nd web_service_call here

.

.

.

"ResponseParam=ResponseBody",

.

BEGIN_ARGUMENTS,

.

.

.

" <bankaccountnumber>{prmBankAccountNumber}</bankaccountnumber>"

" <firstname>{prmFirstName}</firstname>"
" <lastname>{prmLastName}</lastname>"
" <ssn>{prmSSN}</ssn>"
.

.

.

 

END_ARGUMENTS,

.

.

 

 

return 0;
}

 

 

 

 

 

NB: If this solves your problem / helps you on the way, consider acknowledging with Kudos. To kudo a post, select the thumbs up icon in the gray square by the post in the thread.
0 Likes
TRao Absent Member.
Absent Member.

Re: XML Response parsing in VUGen

Hi ,

 

2nd option you suggested looks good. But when I tried, getting into some issues.

 

NumOfValues = lr_xml_get_values("Xml={response}", "Query=//edgNum",
           "SelectAll=yes", 
           "ValueParam=Result", 
           "NotFound=continue",
           LAST);

 

lr_output_message("Value is  {NumOfValues}");

 

 

When I tried above thing, I am getting below output.

Action.c(33): "lr_xml_get_values" succeeded, 3 matches processed

"Action.c(39): Value is  {NumOfValues}"

 

How to get NumOfValues =3 above.

 

Thanks in advance.

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.