OSB shared variable between request and response - variables

I am trying to generate a unique id using fn-bea:uuid() and insert this shared variable into inbound and outbound message.
But I do't know how to create a variable can be shared between request and response. It seems that I can not drag anything before the RouteNode, now I can only have two insert actions one for request and one for response. In this way there will be two different UUIDs. Is there any way I can create a shared variable and insert the same variable into request and response?
Update:
I see if I put a assign activity right before the request's insert.(Screenshot 2) the variable created also can be used in the response insert activity. And I tested it, it is the same value. This works good. But I am having another problem here. I tried to use insert activity insert a the variable into inbound and outbound message. I set it to "as first child of" inbound for request and "as first child of" outbound for response. I can see the variable is successfully added into the inbound message, but the outbound does not work. Just for testing I try to set the insert to "as first child of" header for response, and output the header I can see its added successfully, means its working for header, but not outbound. Any idea why this is happening?

Related

attributes.headers getting lost after a http Request call in Mulesoft?

I am getting some attributes in an API but all getting lost after an HTTP request connector in mule4.
why is it happening?
Look in the connector's configuration properties -> advanced tab for the connector configuration (in this case the HTTP connector's "request" operation) and you'll find a target variable and target value. If you fill in the target with a name - this does an enrichment to avoid overwriting the Mule message. If you leave it blank (the default) it will save the message (attributes, payload) over the top of the existing one - which is what you're seeing now. This mirrors the old mule 3 functionality, but sometimes you want it to leave what you have there alone.
So for the target value you get to pick exactly what gets saved.. If you want just payload: put that in. If you want both payload and attributes - I'd use "message" as that will mean you get both payload and attributes saved in the variable. Of course you may not want as much saved, so feel free to put in whatever dataweave expression you like - so you could even create something with bits from anywhere like:
{
statusCode: attributes.statusCode,
headers: attributes.headers,
payload: payload
}
A connector operation may replace the attributes with those of the operation. If you need to preserve the previous attributes you need to save them to a variable.
This is a default behaviour of MuleSoft. Whenever request crosses to transport barrier it losses existing attributes. You need to preserve attribute before HTTP Request.

Jmeter: variable scope - How to use different random value for the same request

I'm willing to use 2 variables for random values with the same request.
I defined both in User Parameters as follows: var1=${__Random(1,100)}; var2=${__Random(1000,2000)} (Also I checked: Update once per iteration)
I have the requests:
Request1: GET user/${var1}
Request2: GET user/${var2}
During run-time, when it gets to request2 var2 equals var1!
How do I fix that?
Well, User Parameters is a PreProcessor so you should put it as a child of your HTTP Request in order to get correct behavior. You can use Debug Sampler and View Results Tree listener combination to validate variables values (see How to Debug your Apache JMeter Script article for more details)
I would recommend discarding this User Parameters and injecting the __Random() function directly into your HTTP Request sampler Path like
/user/${__Random(1,100,var1)}
/user/${__Random(1000,2000,var2)}
This is a simpler way to generate random numbers and get them stored into JMeter Variables.

Failed to respond to incoming message using data source row correlation

I am totally new to Parasoft virtualize. I created a virtual asset and added three fields in my data source correlation, My request xml has 4 fields. I am getting this error after processing the request.
<Reason>Failed to respond to incoming message using data source row correlation</Reason>
<Details>Values in incoming message did not match values in the data source "GetSubscriptionOperationsRequest"</Details>
Any suggestions on what might be the problem here?
The message which you are getting explains your problem.
The virtual asset cannot correlate your request with data in your data source to build response.
Try to send request with one of the values from column used for Datasource's corelation in your responder.
That value should be in request's filed used by correlation.
Maybe you should try to add catch all responder to see if you have correct corelation between incoming requests and your responder.
You can also ask Parasoft's technical support for help.

Send multiple values for one form param in clj-http?

(defn do-request [url query-map]
"Executes HTTP client"
(client/post url {:form-params query-map}))
(do-request "http://foo.com/api" {:a [val1 val2 val3]})
I need to send multiple values for a single key. The API docs state that I need to pass them like foo.com/api?a=val1&a=val2&a=val3 but when I pass that through clj-http as above it only does foo.com/api?a=val3.
(For more detail, I'm using Authorize.Net's version 3.1 CSV-based API and trying to add x_line_item which is defined to work as above.)
Actually #dAni was correct. Passing a vector as above works correctly. The debugging endpoint output from Authorize.Net only shows the last entry, but if you set the client email to one you control you will see the line items you send listed.

RESTful API - Ignore invalid PUT request?

I build a simple API for a bookmark manager, where the URL of record should only be stored once. Record 001 with www.example.com already exists beside record 002 with www.stuff.com.
If I update record 002 with the url www.example.com, should I ignore the complete request and send back an error message or is it better to update all valid parts and just send an errror message, that says, that the url/bookmark already exists?
With a PUT, the expectation is that the entire operation will succeed or fail:
The PUT method requests that the state of the target resource be
created or replaced with the state defined by the representation
enclosed in the request message payload. A successful PUT of a given
representation would suggest that a subsequent GET on that same
target resource will result in an equivalent representation being
sent in a 200 (OK) response.
https://www.rfc-editor.org/rfc/rfc7231#section-4.3.4
You should send an error for an invalid PUT (since the URL already exists and cannot be in two records at the same time) and not apply any of the other updates.
For partial updates you might consider a PATCH, but in this case I don't think you would go this direction since:
If the entire patch document
cannot be successfully applied, then the server MUST NOT apply any of
the changes.
https://www.rfc-editor.org/rfc/rfc5789