SoapUI (non pro) Property Transfer getting the basics going using XPath - xpath

Preamble: First off - I am a complete novice, and have zero clue what I am doing, apologies in advance.
Question:
I have working SOAP messages in SoapUI (regular flavour) that I have valid responses to. I am trying to build a set of test steps that can complete a transaction lifecycle for testing.
I only just figured out that Property Transfer could be used to take a response from call A to be used in call B.
I have the source declared correctly, and the Target correctly, With the default namespace info I have successfully transferred the complete response of call A into the target property. Now I just need to cut that down to one element only. I have tried all manner of things, but I seem to be getting [null] every time (except where I don't include the bit to choose one element at all, as noted above).
I just don't know what the format of the line that specifies the desired field should be. I know I have to have the name of the desired field in it, near the end, but beyond that I am randomly trying all sorts.

Okay, I have it solved, after many stupid trials and errors. For posterity and so I can reference it myself in future, this is what I got going:
Inside the soap message response body, there is a tag ns1 (which I am guessing is namespace 1).
Inside that is a section called salesInvoiceReturn.
Inside that is another section called salesInvoiceDetails.
Inside that is a field that I need is called salesInvoiceSalesTax.
So my line in the XPath Source section that works reads:
//ns1:salesInvoiceReturn/salesInvoiceDetails/salesInvoiceSalesTax
Pressing the Run button shows me it captures the correct value into the Custom Property I selected. I don't seem to need any code at all in the Target section.

Related

Go Template - calling another template with multiple parameters

I'm using an application that is getting me some data, and then renders a config file based on a given Go Template. You basically pass a template you've made as a parameter, and app does it's job with it. The template is getting bigger and bigger, so I wanted to wrap some common stuff into sub-templates (I mean, {{ define x }}). The problem I'm occuring is that the sub-template should be passed serveral parameters, which are not a part of my 'dot', and I can't really find a way to do this in Go.
The best answer I've found is to write some 'dict' function myself, and then use it inside the template, but that would mean I basically need to fork the whole application I'm using to render the template, do like 10-15 line changes, and then use this modified versions, which is a nonsense.
I'm wondering if there's any real solution for my problem without having to do some crazy forking and writing custom methods on application side?
Edit:
I've already checked Calling a template with several pipeline parameters before, although it's not answering my question, since I need a way to do this using only template file.

How do I call a c function on each occurrence in LoadRunner?

So there is this HUGE JSON that I am loading from a file and than I run it through lr_eval_string and save it to a parameter. This parameter is later used as a body in one of my REST calls.
I use lr_eval_string to dynamically replace different values in that JSON.
Now here is the problem, one of the values that I replace is unique and generated by a c function. This value appears numerous times in that JSON and needs to be unique each time, yet I am only able to call that c function once at the beginning of the action. The result is that all values end up being equal...
So my question is: how can I call my function each time this unique value appears? I am talking about functionality similar to "Update value on: Each occurrence" that is available on the Parameters section.
I see an option called "User Defined Function" in parameters which I guess could do what I am looking for yet I couldn't find any good tutorial on how to actually use this functionality. Is user defined action the way to go, is there any other solution?
Any help would be highly appreciated! :)

SoapUI and Excel: empty values vs. no value

I am using SoapUI Pro 4.5.2 to read data from spreadsheets, put them into Soap requests to my web service, and get responses back to write to a spreadsheet. It's working.
I have two fields in the input data pertinent to my question:
Middle name is defined as a string of 4 characters, and as minOccurs = 1 and maxOccurs = 1.
Postal extension code (the 4-digit number that is optional after the normal 5-digit code) is defined as a string of 4 digits. This field is optional, so it is marked as minOccurs=0 and maxOccurs=1.
When I use the SoapUI UI interface to send a request, this works fine; if there's no value for middle name, SoapUI generates an empty tag and sends it (I guess because of the minOccurs=1). If there's no value for PostalCode, it does not send any tag at all (I guess because of minOccurs=0).
When SoapUI reads data from an Excel spreadsheet, however, the response to the same data is an error indicating that the extended postal code value of '' is not legal, because it must be 4 digits. It appears that SoapUI generates an empty tag for the extended postal code when reading data from the spreadsheet, and sends it.
I found the "Remove Empty Content" option for SoapUI requests, default to false. I set it to true, and now get an error back from validation indicating that middle name is required but not found. I'm guessing that the remove empty content removed all the empty content (reasonable enough), and middle name has to be there, even if empty, because of the minOccurs=1.
Do I have any way out of this tail-chasing problem? I suppose I'm looking for something like a conditional for the output of the postal extension code, so I can eliminate it if it's empty, even if reading values from the spreadsheet.
I am also curious if there are XSD fixes, but I greatly prefer a fix that doesn't involve changing the XSD -- that becomes a political matter.
EDIT FOR DETAIL:
To put input into the request: I have used the SoapUI UI to choose "properties" from the input spreadsheet for each of the input fields; when that's done, one ends up with values in the request fields like:
${SpreadsheetInput#FrstNm}
Where SpreadsheetInput is the name of the datasource step reading the spreadsheet, and FrstNm is one of the properties. I do this with the "Get Data" option off the popup menu you get by right-clicking the request input field, but there may be other ways.
So first your problem:
Remember that internally to SoapUI almost everything is a string. Doing something like:
<postCode>${SpreadsheetInput#PostCode}</postCode>
in your SOAP request, assuming PostCode is either blank or does not exist outright, will expand to:
<postCode></postCode>
and SoapUI will even optimize it to:
</postCode>
Then your validation kicks in, which says you do not need to provide this element, but if you do, it had better be 4-characters long. Which the above fails.
The solution:
You need to pragmatically (meaning you will have to write Groovy code) create this node in your request. There are several ways to handle this. The quick and dirty is with a Groovy step, that goes something like:
def postCode = context.expand('${SpreadsheetInput#PostCode}').trim()
if (postCode != null && postCode != '')
testRunner.testCase.setpropertyValue("postCodeNode", "<postCode>" + postCode + "</postCode>")
else
testRunner.testCase.setpropertyValue("postCodeNode", "")
Then in your request replace the original:
<postCode>${SpreadsheetInput#PostCode}</postCode>
with just:
${#TestCase#postCodeNode}
Notice, the XML node elements are part of the SoapUI property! Again: everything in SoapUI is just a plain string.
If you want something more hard-core, have a look at
dynamically create elements in a SoapUI request. This is mine.

Passing values between cucumber statements

I'm running in to an issue in that I need to get one value in a cucumber statement, and then give that value to another statement.
Specifically I am getting a JSON object from one page (where that object gets sent to an api endpoint as a preference) and then using information out of that after I query the api, which happens in a completely separate step.
I am suspecting that I have to write the value somewhere, and then pull that value when the step that needs it comes up, but I'm kind of at a loss for doing that as well.
I can provide any further needed details, thanks for any help!
Definitely a rookie question - to which the answer is to use instance variables - #variable_name = get_method in the helper method your step calls.

ajax send parameter to jsp but failed

I am trying to send data to my jsp via:"xhr.send(projectCode);"
but apparently the parameter is not received when I am trying to realise it with System.out.print it is a null displayed.
so the story from the begining. my javascript function send the parameter to the jsp whitch construct an xml file and resend to the first one.
this will reconstruct my second dropdownList with the xml code constructed and received.
so the problem that the parameter dosent sent at all.
What should I do.
Just note in case the syntax whatever you have sent is like this:
url="postjob2.jsp?param=" + param;
After param=" keep a space and then the parameter. My issue got resolved as soon as I entered the space.
The simplest all-round solution is to run your application with a HTTP-tracer, such as fiddler for windows or wireshark. In that way you can see if the proper data is being submitted from your client to the server Given the amount of details you provide, I think this is the best starting point

Resources