When using the Property Transfert window to transfert a XML node (with children nodes) taken from the response of a first Soap request to a second Soap request, and that both requests are in the same TestCase, it works great :
TestCase 1 :
Source : [First Soap Request] Property : [Response]
declare namespace ns='http://xxx.com';
//ns:xxxxx[1]/ns:return[1]
-------------------------------------------
Target : [Second Soap Request] Property : [Request]
declare namespace ser='http://xxx.com';
//ser:xxxxx[1]/ser:someobject[1]
But if the two requests are in different TestCases, I guess it is required to save the XML node to a TestSuite property first, and then transfert this property to the new Soap request :
TestCase 1 :
Source : [First Soap Request] Property : [Response]
declare namespace ns='http://xxx.com';
//ns:xxxxx[1]/ns:return[1]
-------------------------------------------
Target : [TestSuite1] Property : [myVariableToTransfert]
TestCase 2 :
Source : [TestSuite1] Property : [myVariableToTransfert]
-------------------------------------------
Target : [Second Soap Request] Property : [Request]
declare namespace ser='http://xxx.com';
//ser:xxxxx[1]/ser:someobject[1]
This doesn't work!
It seems I'm unable to get valid XML in the second request when it is taken from the TestSuite as a property. Sometimes the value is null, sometimes it is wrapped in CDATA tags or the XML is entitized ("<" are "<", for example). I'm unable to get the value as real XML, like when both requests are in the same TestCase!
I played with the "Transfert Text Content", "Entitize tranfererred value(s)" and "Transfert Child Nodes" options but without success!
How can I tranfert a XML node from a request in a TestCase to a request in a second TestCase?
Set your response value as custom property at test suite and then you can use this for further testing..remember it will save your value as string data so if you are saving your integer data then you have to covert it into integer before further use.Like
testRunner.testCase.testSuite.getPropertyValue("").toInteger()
Here is the detailed explanation:
Create test suite 1 and the below steps
test case 1
DataGen step
test case 2
Within the DataGen step, open the editor, add new property via clicking on "+" button and select script as Type (you should also give a name to the property now assume the name is yourprop).
At the below side of the screen you should see the script editor. And create a script as below (please notie that you should change the variables according to your web service and XML)
def testXML = context.expand( '${Test Request#Response#declare namespace ns1=\'http://namespace/'; //ns1:WebServiceNameResponse[1]/ns1:nodeName[1]}' )
Now you have created a soapUI property via DataGen named yourprop. You can use this property within the test suite for the following test cases.
I hope this helps, if you are not satisfied or you face any problem please let me know I will do my best.
Related
I have tried to create a record of my customized object through REST service in IBM Maximo.
The problem is that I created the record but I can't assign values to the attributes.
Next I will show what I did and what happened:
I have an Object Structure called oxidato that represents my customized object.
I did a POST using POSTMAN to this URL:
http://hostname:port/maximo/oslc/os/oxidato?lean=1
In the body section this is the JSON I was trying to send:
{
"attribute1":"205",
"attribute2":"206"
}
The record was created but none of the attributes was filled.
In my opinion, the REST service received the POST but canĀ“t read the body.
What am I missing? I add an image of the POSTMAN as example:
EDIT1: I update the POST in order to use the newest API RES (Thanks Dex!)
EDIT2: I add an image of the header
I have found that Maximo will often ignore incoming attributes that aren't in the Maximo namespace (http://www.ibm.com/maximo). You could go through the trouble of setting up your VALOR1 and VALOR2 attributes to be in that namespace, but it's easier to just tell OSLC to ignore namespaces. You do that by setting the "lean" parameter to "1".
In your case, go to the "Params" tab and add an entry with a name of "lean". Give it a value of "1" and then send your POST again. You should see "?lean=1" appear at the end of the POST URL along the top there, but your body content should remain unchanged.
EDIT:
On the other hand, it looks like (based on your URL) that you aren't actually using the newer JSON/OSLC REST API; It looks like you are using the older REST services. This IBM page gives you a lot of information on the newer JSON REST API, including the correct URLs for it: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html.
You should change your URL to /maximo/oslc/os/oxidato to use the newer API that naturally supports JSON and the lean parameter described above. This does required Maximo 7.6 to use though.
EDIT 2:
The attributes are often oddly case sensitive, requiring lowercase. Your example in your question of "attribute1" and "attribute2" are properly lowercase, but your screenshot shows uppercase attribute names. Try changing them to "valor1" and "valor2". Also, these are persistent attributes, right?
The response code received back (e.g. 200 - OK) and the response body will detail the record that was created.
I think you are correct in that the body of the post request is being ignored. Provided there are no required fields on the custom MBO your POST is probably creating an empty record with the next value in the sequence for the key field but you should see that in the response.
The following POST should create a record with values provided for attribute1 and attribute2 and provide a response with the record's identifier so that you can look it up in Maximo and show the values that were stored for attribute1 and attribute2:
http://hostname:port/maximo/rest/os/oxidato/?_format=json&_compact=1&attribute1=205&attribute2=206
Response: 200 OK
Reponse Body:
{ "CreateOXIDATOResponse": {
"rsStart": 0,
"rsCount": 1,
"rsTotal": 1,
"OXIDATOSet": {
"OXIDATO": {
"rowstamp": "[0 0 0 0 0 -43 127 13]",
"ATTRIBUTE1": "205",
"ATTRIBUTE2": "206",
"OXIDATOID": 13
}
} } }
You may also want to turn on debug logging for the REST interface in System Configuration -> Platform Configuration -> Logging for additional detail on what's happening in the log file.
I'm using SoapUI to call a web service.
I have two call, one returns an id to me, the second one use this id to make his request.
This is how the second call looks like:
https://example.com/something/{id}
With the property transfer, I have no problem retrieving the id from the first call. But when I try to add it to my endpoint (Property transfer -> Target: XXX, Property: Endpoint), the whole Endpoint is replaced by {id}.
I know I probably need to write something on the "box" belove the "Target" line, but I have no idea what.
I already tried to google it, but I seem to only found answers which are using a Groovy script and this sounds way too complicated for what I want to do. Surely, there is an easy way to do this?
Add a Properties teststep to your testcase.
Add a parameter to the Properties teststep named "id"
Change your property transfer teststep to target id inside Properties
Now open your second call, and change the value of the id parameter to ${Properties#id} and the id from your Properties teststep should be used as the value.
Your REST Request teststep should look something like this.
The "/value" at the top right, is there because I actually typed in "value" in the Properties teststep in the id parameter
If you are having problems getting your request to look something like that, try creating a new REST Request teststep, and then choose to create a new Rest request, and then type in something like
http://example.com/{id}
...when prompted for the endpoint.
I'm newbie to soap and soapui, I'm trying to create a test case in which I will send the same request(XML attachment) many times(about 500), the problem is that each time I need to increment/change a value in the request (the id).
Therefore, I wonder if the is a way to pass this parameter to the attached xml file ? or if there is another ways to do the test case.
Thank you in advance
UPDATE
here is the content of the xml file :
<mod:sendMSG xmlns:mod="http://test.soap/service/model">
<id>${#Project#parameter1}</id>
<date>2016-04-03T04:03:00</date>
<infos>
<firstName>AT </firstName>
<lastName>AT </lastName>
......
</infos>
</mod:sendMSG>
which is included in the soap request, ass shown in the following image :
Test steps:
Groovy Script
SOAP Request (disabled)
I disabled the SOAP Request because it runs once more after the script has already looped the request x times.
Groovy script:
int loops = 500;
for ( iter in 1..loops ) {
//Overwrite the 'parameter1' property at project level
testRunner.testCase.testSuite.project.setPropertyValue("parameter1", iter.toString())
//log.info("iter: " + testRunner.testCase.testSuite.project.getPropertyValue("parameter1"));
// Run the teststep named 'SOAP Request'
def testStep = testRunner.testCase.testSteps['SOAP Request'];
testStep.run( testRunner, context )
}
Now you should be able to run your TestCase. I recommend saving your project before, I had some problems with SoapUI crashing on me when running.
Using API Gateway, I would like to intercept the Integration Request, change the model and then forward it through to the endpoint via a body mapping template.
For example, I would like to change the MatterGUID property to be MatterId + value.
If i include my entire model within the template, it works fine;
#set($inputRoot = $input.path('$'))
{
"Property1" : "$inputRoot.Property1",
"MatterId" : "$inputRoot.MatterGUID",
"Property2" : "$inputRoot.Property2",
"Property3" : "$inputRoot.Property3"
}
However, I would like to update my model by updating only the field needing to be changed. i.e. something like:
#set($inputRoot = $input.path('$'))
{
"MatterId" : "$inputRoot.MatterGUID"
}
However, doing that will pass only the MatterId through to the endpoint, not all the other properties - I can understand why that happens but would like to know what i'm missing in order to include the entire object but with the changed MatterGUID value.
Almost like if I could run a replaceAll on the model and for it to affect only the property I'd like:
$inputRoot.Replace("MatterGUID", "MatterId")
The model is not the source of truth on what the payload should contain, the mapping template is. It is currently not possible to include properties within the payload that are defined in the model and not present in the mapping template.
I'm creating a test case for a REST API in soapUI 4.5 where I'm going to use the content from step X to make a new call in step Y.
Ideally I'd create the REST request with some parameters, say A and B, and say that these parameters should be used in the URL:
http://myapi.com/v1/stuff/A/B
Then I'd do a property transfer step and simply set values extracted from step X into A and B.
It looks as if soapUI only lets me create querystring parameters, like this:
http://myapi.com/v1/stuff?ParamA=A&ParamB=B
This works of course, but I'd like to be able to call it both ways, to verify they're both working.
Am I missing something?
I am not a soapui expert by any means, but have just worked through a very similar scenario, so this might help you out.
Part 1: Create a paramatized resource
In my service, I have a resource called stuff:
http://{host}/stuff
I create a child resource with the below values:
Resource Name: Get stuff by ID
Resource Path/Endpoint: {stuffId}
and before clicking ok, click Extract Params - this will populate the Parameters table with an entry like:
Name | Default value | Style | Location
stuffId | stuffId | TEMPLATE | RESOURCE
then click ok. You now have a resource that allows you to dynamically supply an id:
http://{host}/stuff/{id}
you would need to repeat this to create the B parameter above (or you could create A and B as two parameters to the single resource if you never call /stuff/A without also supplying B).
Part 2: Create the test case
Now in the test case, you need to retrieve A, transfer the property, and then send a request to the above resource using the property:
In the test case, create the request to retrieve the response containing A
Right click the testcase and add a Properties step. Add a property to store the value of A.
From the response in the Outline view, right click the value of A and select "Transfer to > Property", select the property you just created and hit ok
Create a new request, using the new paramatized resource created in the first part. In the place of the id, put a reference to the property which is holding the value of A in this format:
${propertyName}
I might have done something wrong, but my test initially fails on the property transfer with "Missing source property". In the Source are of the PropertyTransfer step, I needed to set the property to ResponseAsXml
Hope this helps!