Cannot Set Value to Variable in Mule ESB - web-services

I tried to get value from soap using Web Consumer, then I want to get the value with set-variable.
the problem, i can get the value to input in set-variabel.
this the design.
view image

Not sure if I understand your question, but I think you are trying to extract value from SOAP response. If this is the case, then note that Web Service consumer returns NamespaceRestorerXMLStreamReader.
You can drag "Transform Message" which is Mule DataWeave Transform Component from palette and drop it after Web Service Consumer component. You will then notice response structure in the left hand side. Define appropriate output format in right side and map the elements as needed.
You can then extract values to store in flow variable and continue with further logic.

Add a dom to xml the use xpath in a variable to pick the value

Related

Can You Read a Cookie in Google Tag Manager That Doesn't Have a Set Name?

I can read first party cookies that have set names just fine in Google Tag Manager. However I have come across a few instances where the cookie name is session based and there isn't a name set consistently for me to check against. I want to know if the cookie is set and ideally read the data.
For instance
cookie_name_123456
cookie_name_234567
cookie_name_345678
It doesn't look like the name field takes regular expressions. Anyone know a way to setup GTM to read a cookie like that?
You can create a custom HTML tag with a Javascript that reads the document.cookie property, and split in by the delimiter to get an array with individual cookies (document.cookie.split(";")).
This gives you an Array with all first party cookies that are not flagged as "http only" (those are not accessible with JS). Each array entry will have the format of "cookiename equals value" (e.g. "_ga=GA1.2.1545993750.1587886865" would be the Universal Analytics cookie "_ga" with a client id as value). You can then loop over the array.
Inside the loop you can split each array entry by the "=" sign to get arrays with two elements, [0] for name and 1 for value. You then apply your regex to the name. If the rexeg matches what you are looking for, you can push the value to the dataLayer.
To make sure this has run before the tag that will be using the cookie value, you can use tag sequencing. If you manage your sequence via the onHtmlSuccess() and onHtmlFailure() functions as explained e.g. here in Simo's blog you can set the sequence so that the tags are only fired when the cookie value is actually there.
Alas it is not possible to do this in a custom template, which would be so much more elegant, but the sandboxed JS inside custom templates cannot access global document properties.

WS2ESB: Store state between sequence invocations

I was wondering about the proper way to store state between sequence invocations in WSO2ESB. In other words, if I have a scheduled task that invokes sequence S, at the end of iteration 0 I want to store some String variable (lets' call it ID), and then I want to read this ID at the start (or in the middle) of iteration 1, and so on.
To be more precise, I want to get a list of new SMS messages from an existing service, Twilio to be exact. However, Twilio only lets me get messages for selected days, i.e. there's no way for me to say give me only new messages (since I last checked / newer than certain message ID). Therefore, I'd like to create a scheduled task that will query Twilio and pass only new messages via REST call to my service. In order to do this, my sequence needs to query Twilio and then go through the returned list of messages, and discard messages that were already reported in the previous invocation. Now, to do this I need to store some state between different task/sequence invocations, i.e. at the end of the sequence I need to store the ID of the newest message in the current batch. This ID can then be used in subsequent invocation to determine which messages were already reported in the previous invocation.
I could use DBLookup and DB Report mediators, but it seems like an overkill (using a database to store a single string) and not very performance friendly. On the other hand, as far as I can see Class mediators are instantiated as singletons, therefore I could create a custom Class mediator that would manage this state and filter the list of messages to be sent to my service. I am quite sure that this will work, but I was wondering if this is the way to go, or there might be a more elegant solution that I missed.
We can think of 3 options here.
Using DBLookup/Report as you've suggested
Using the Carbon registry to store the values (this again uses DBs in the back end)
Using a Custom mediator to hold the state and read/write it from/to properties
Out of these three, obviously the third one will deliver the best performance since everything will be in-memory. It's also quite simple to implement and sometime back I did something similar and wrote a blog post here.
But on the other hand, the first two options can keep the state even when the server crashes, if it's a concern for your use case.
Since esb 490 you can persist and read properties from registry using property mediator.
https://docs.wso2.com/display/ESB490/Property+Mediator

How to in JMeter use regular expression extractor to fill request in loop

I've got simple test plan:
Jdbs Conection
JDBC request
For Each Loop on jdbc response
|-Regular Expression Extractor (Post processor)
|-Soap Request where I need extracted value from Regular Expression Extractor
|-Response assertion
The problem is when the first loop is executed. SOAP request is filled with name of variable from Regular Expression Extractor not the value. Can anyone tell me how to get around this problem?
[Edit] test plan screen
As you can see on the first image is showing jdbc response data . On first position is value '22;1'. Second one is showing first soap request failed not a values but names of variables... Third one is showing second request filled correctly
http://postimg.org/image/owl5kue4v/
Below is screen when I add Debug Sampler to for each loop. In this situation first SOAP request is filled correctly.
http://postimg.org/image/aad3c0ngt/
My problem is how to get the same behavior like in second situation but without adding Debug Sampler?
BTW, Sorry for the images on an external server, but my rank is too low to add them here
Your test plan should be in the format mentioned in the attached snapshot:
Hope this will help

Load testing with SOAP UI

I have a SOAP UI 4.5.1, I have made a load test, it is working fine. My problem is that I run the same request every time and I need to change the values of the soap request I am sending.
For e.g. I have a block of my soap request:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
Provider ID: SHL
Project ID: SampleAssessment
Is there a way to make those values changing from some kind of interval?
For e.g.: Provider IDs [SHL, SLH, LHS]
Project IDs [SampleAssessment, TestAssessment, AnotherAssessment]
And with a load test I am making three request so that for the first request values looks like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
for the second like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SLH</ns:ProviderId>
<ns:ProjectId>TestAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
and so on...
Is there a way to make this happen with SOAP UI?
From my experience, you will need to use a Groovy Script step.
For example, if you have a step before your request that is a script, you can use something like:
context.setProperty("ProviderId", "SHL")
Then in your request, use:
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Of course, this doesn't buy you much by itself. There are few ways to vary what the context.setProperty("ProviderId", "SHL") line will set. You can create a collection and iterate over it using something like:
def providers = ['ABC', 'DEF', 'GHI', 'JKL']
providers.each() {
context.setProperty("ProviderId", it)
testRunner.runTestStepByName( "nameofteststep" )
}
Where "nameofteststep" is the name of the Soap Request test step. This might sound odd, but if you right click the test step and disable it, the groovy script will still be able to execute it but it will not run sequentially. By that I mean that the groovy script will run it 4 times, but it won't run a fifth time when the script is complete because it is after the script. Then you just need to keep in mind that each load test thread makes four requests, but I am pretty sure that the SoapUI statistics will take this into account for you... might want to keep an eye out for it, though.
Alternatively, you could check the 'threadIndex' and set a the context variable based on that. A bit like this here: Log ThreadCount.
You could also use a collection without a loop and increment an index that you save as a testcase property and send the string corresponding to the index.
Personally, I think the first way is the most straightforward but I can provide an example of the other ones if you like.
There is a simple way of doing this without writing a groovy script.
After creating a test case you should include the below test steps:
1-Data source
2-Request
3-Loop
Data source will read an excel file (or other data source methods such as XML, groovy, JDBC, gird .. however the excel is the simplest one).
You should include the datas (that you need to change within the request)
Within the test request you need the right click and select "get data" . please notice that your test request should be as below
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Then the last step is the "Loop" . This for returning to the first step until the data ends.
I hope this helps.

CAML query in getLIstItems method returns no rows of items

I am invoking Sharepoint's List Web services and using the getListItems() method. In particular, I am keen on specifying a CAML query because I really want it to just retrieve one item that I am specifically interested in. This I am doing by specifying a query in my XML string, in varying degrees of combinations, either by specifying the EncodedAbsUrl, the LinkFileName, the URL or the FileRef, with most results returning 0.
The XML query looks like this :
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body><GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{5cbc4407-3851-4e00-964a-bb7e9b430f9f}</listName> <viewName></viewName> <rowLimit>1000</rowLimit> <webID></webID>
**<query><Query><Where><Eq><FieldRef Name = "FileRef"/><Value Type = "Text">"/Shared%20Documents/Ashish/Word_feb27.doc"</Value></Eq></Where></Query></query>**
<viewFields><ViewFields><FieldRef Name="FSObjType"/><FieldRef Name="LinkFilename"/><FieldRef Name="UniqueId"/><FieldRef Name="FileRef"/><FieldRef Name="FileRef"/><FieldRef Name="EncodedAbsUrl"/><FieldRef Name="FileSizeDisplay"/><FieldRef Name="_UIVersionString"/><FieldRef Name="_owshiddenversion"/></ViewFields></viewFields></GetListItems> </S:Body></S:Envelope>
Without the tags this Soap request does infact work, and it retrieves all the items that area available in the List. The frustration begins when i specify the query tag. In particular the Following combinations have been attempted by me
FieldRef.name = {LinkFileName, EncodedAbsUrl, URL,FileRef} and Value.type = {Text, URL}
Either they yield results with no 0 fields in it or they return internal errors. I figure, this is a syntactical issue and would rather shoot this question to you guys who have probably dunnit in the past to see where I am possibly messing it up.
Thanks
I would recommend using CAML Query Builder and Fiddler. Query builder can connect SP using Web services and you can build the query with that. After you got your expected results, capture the Web service request with Fiddler and use it :)
BTW: Have you considered using Sharepoint Client Object model? You do not have to worry about SOAP messages.
Remove the <query><Query> tags.