Web Services - Using 'lr_xml_extract' to capture SOAP response - Help!

475 views
Skip to first unread message

kaostheory1

unread,
Nov 8, 2010, 9:25:12 PM11/8/10
to LoadRunner
Greetings -

I am very new to working with Web Services in Vugen and have a new
project that I inherited from someone else that is all Web Services so
needless to say I could use a few pointers.

My delemma is that I don't exactly understand how to use
'lr_xml_extract' properly (and clearly other pieces of the web service
puzzle) and I would like to re-use some of the code the prior engineer
used for a similar script of which I have as an example. I can pretty
much understand what they were trying to do with the above noted
exception, any help would be appreciated...

Below is an excerpt from the script, the names have been changed to
protect the innocent = )

--------------------------------------------------------------------------
TOP OF THE SCRIPT I AM TRYING TO EMULATE
------------------------------------------------------------------------

Action()
{

int result;
int i;
char status[300] = "<factor lbl=\"Some_Value\" value=\"$7.49\"></
factor>";

lr_think_time(20);

lr_start_transaction("Blah_001_SubmitRequest");

soap_request("StepName=SOAP Request",
"URL=http://blah.blarger.com/thing/submit.do",
"SOAPEnvelope="

-----------------------------------------------------------------------------------------------------------

BOTTOM OF SCRIPT AFTER SOAP ENVELOPE
----------------------------------------------------------------------------------------------------------

"SOAPAction=",
"ResponseParam=response1",
"Snapshot=t1283439504.inf",
LAST);

lr_xml_extract("XML={response1}",
"FastQuery=/User/Group/BView/Output[2]/View/
someFactors/something/factor",
"XMLFragmentParam=ParamXml_factor",
LAST);

result = stricmp( status,lr_eval_string("{ParamXml_factor}") );

if (i==result)
{

lr_end_transaction("ALPS_Calculation_001_SubmitRequest", LR_PASS);

}
else
{
lr_end_transaction("ALPS_Calculation_001_SubmitRequest", LR_FAIL);

lr_think_time(20);

return 0;
}

****************************************************************************
***** So the biggest issue I am having in terms of understanding this
script and the use of 'lr_xml_extract' is the "FastQuery=" arguement
and the use of the XPATH?. In this example the FastQuery arguement
is " "FastQuery=/User/Group/BView/Output[2]/View/someFactors/
something/factor", which is the XPATH? to the data that is assigned at
the top of the script to the char "status" to be matched on as a
success, this was seemlingly done arbitrarily as there are many other
elements with data in the response that could have been used to match
against, is there a simple consistent way to match a successful SOAP
response that is commonly utilized? Is there a tool that might aid
in the capturing/manipulation of the SOAP response?

Any help is greatly appreciated....

Thanks!


Yaron Naveh

unread,
Nov 10, 2010, 1:49:44 PM11/10/10
to LoadRunner
Hi

FastQuery is a simplified XPath query.

Can you elaborate more on what you are asking - do you want to know
how to add an assertion to a soap call response?

Thanks,
Yaron

Web services testing blog
http://webservices20.blogspot.com/

kaostheory1

unread,
Nov 11, 2010, 11:47:04 AM11/11/10
to LoadRunner
Thank you for your response, in re-reading my original note I see I
might have gotten carried away a bit talking through the issue, my
apologies.

To clarify, you are correct I am trying to figure out how to add an
assertion to the script to validate a successful soap response.

More specifically, I would like to know if there is a 'best practice'
for doing so with web services? It 'appears' as if the piece of
response being matched on in my example above was chosen somewhat
arbitrarily , so I was curious if there was some standard for doing
this the same way for every soap request I am scripting or if I indeed
have to match on some random piece of the response that is specific to
each call?

I appreciate your time and consideration...


-k

On Nov 10, 1:49 pm, Yaron Naveh <yaron...@gmail.com> wrote:
> Hi
>
> FastQuery is a simplified XPath query.
>
> Can you elaborate more on what you are asking - do you want to know
> how to add an assertion to a soap call response?
>
> Thanks,
> Yaron
>
> Web services testing bloghttp://webservices20.blogspot.com/
> > Thanks!- Hide quoted text -
>
> - Show quoted text -

Floris Kraak

unread,
Nov 12, 2010, 3:12:31 AM11/12/10
to lr-loa...@googlegroups.com
On Thu, Nov 11, 2010 at 5:47 PM, kaostheory1 <kaost...@gmail.com> wrote:
>
> More specifically, I would like to know  if there is a 'best practice'
> for doing so with web services?   It 'appears' as if the piece of
> response being matched on in my example above was chosen somewhat
> arbitrarily , so I was curious if there was some standard for doing
> this the same way for every soap request I am scripting or if I indeed
> have to match on some random piece of the response that is specific to
> each call?
>
> I appreciate your time and consideration...
>

Common sense applies, just as with web.


Ask yourself: What criteria would you use to say "this transaction did
what it was supposed to do?"

Basically, you check for two things: Confirmation of success, and
signs of problems.

Confirmation of success:
- If you requested a specific piece of data, add a check that tests if
the requested data is present and looks how that data is supposed to
look. If you know the answer in advance, check if the answer matches
that.
- If you requested some action to be performed, check the result to
see if the action was performed successfully.

Signs of problems:
- If you see errors during scripting this, or have a list of known
error codes, check for them in the negative.
- If you know what error messages look like in general (specific tags
denoting errors) check for them in the negative, and if at all
possible save the error message so you can pass the error to your
tools.

It doesn't really matter what protocol you're using, really.

Regards,
Floris
---
'Apple says "you can't distribute this iPhone app in any form or
through any means unless we explicitly allow you to do so, and you
can't allow others to disobey this rule".
GPL says: "you can distribute this iPhone app in any forms and through
any means you want, and you can't prevent others to do so".
Do I sense a subtle opposition?'
   --- Gabriel Morin

Reply all
Reply to author
Forward
0 new messages