In MUnit Mock Message Processor how do we specify a non specific payload such as Mule Message Collection (comma separated XML data) in the return with message payload field.
In general if we just hard code the value, it would be taken as a string which makes it difficult to read it further.
How can we specify the data type as Mule Message Collection ?
Please help me out with this .
Thanks in Advance.
Use MEL expressions to create a collection. Based on your example a comma separated list of strings, you can use MEL with any Java/MVEL operations to create a list from that:
<mock:then-return payload="#[Arrays.asList(('${mycommaseparatedlistofstrings}'.split(',')))]" />
Related
I am starting to work with wso2 esb from few days back.
I need to read particular column value and set into property in wso2 esb.
My .txt file contains following values:
**SNO|FIRSTNAME|LASTNAME|EMAIL|PHONE|ADDRESS|SELLING_DEALER**
**51|christopher|chris|cpko78#gmail.com|0406-755909|US|MacGgor**
I need to read email and phone column value from this .txt file and set into property which can be used for further operations like EmailValidation or PhoneValidation.
Can anyone help me out to fine solution?
If you use ESB one option would be to do a smooks transformation into xml and then read the values from the generated xml. Just keep in mind that if you need the original csv content later in your proxy/api, you need to store the original content and restore it after you've read the needed values (using enrich mediator).
https://docs.wso2.com/display/ESB481/Smooks+Mediator
Another option would be to do a xslt transformation into xml (similar to smooks).
https://docs.wso2.com/display/ESB481/XSLT+Mediator
The last option I could think of is using the script mediator and extract the values using JavaScript, Groovy, or Ruby.
https://docs.wso2.com/display/ESB481/Script+Mediator
If you use EI then you also might expose your csv as a data service.
https://docs.wso2.com/display/DSS351/Exposing+CSV+Data+as+a+Data+Service
Hope that helps.
I have an xml document with a node that may optionally contain a string of escaped xml. I'd like to be able to transform that content using xsl in a BizTalk map. Any suggestion how?
I've tried:
msxsl:node-set(string). This creates a nameless single node with no content.
The document() function using a url prefix of 'data:text/xml' as suggested by helderdarocha here.
for-each selecting the text() of the node containing the string
using xpath() in an orchestration to extract the string then make a multipart message. It won't let me use an xmlDocument message as one of the messages in a multipart message transform.
Do I have to use a C# helper assembly to accomplish this?
I have tackled a similar issue in a project, where I have a series of 2 mappings (both native xslt).
The first map will map your input document to an intermediate format. This format has one "any" node (instead of the escaped XML node), where eventually, I put in the unescaped XML. I unescape using a C# extension object.
The C# code could just be a wrapper for System.Web.HttpUtility.HtmlDecode()
In the second mapping, you can map using plain XPath.
Example Input message:
<root>
<someNode>blabla</someNode>
<any><root2><myValue>escapedXml</myValue></root2></any>
</root>
Intermediate format:
<root>
<someNode>blabla</someNode>
<any>
<root2>
<myValue>escapedXml</myValue>
</root2>
</any>
</root>
In your second mapping, you could use XPaths like /root/any/root2/myValue/text() without any issue.
Important Note:
If you need to do XSD validation against this intermediate format, this is a good way to do this as well. You would just need to create the appropriate intermediate XSD according to your needs. In my case this was needed, so I had to validate this unescaped format using a receive pipeline execution in an orchestration.
I need the value in input variable to be added to soap header, using Dataweave - I was using datamapper earlier, but since it's no more supported, want to do through Dataweave.
I'm not able to map between the data variable and outbound property in Anypoint studio. I even tried with multiple variables but no use.
Does anyone has an example?
I was able to set an outbound property from a flow variable using the 'Output' drop down in DW, choose 'Outbound Property'. This feature is described here, see section 'Handling Multiple Outputs'.
My app receive GET requests with URL query parameters. I would like to transfer this request to another app as POST request. I want that the query parameters will appear in the POST request inside the body as json.
Input GET url for example: http://localhost:8081/?name=John&age=30&gender=male
Expected POST json payload: {"name":"John", "age":30, "gender":"male"}
I think that I should use 'Data Mapper' for that, yet I failed to do so.
In the 'input' section I define the source to be - Inbound Property - http.query.params and type Map<String,String>.
In the output section I want the type to be json.
I can't debug/print the result of this mapping so I can't see what is the outcome of my definition. Is this the correct definition?
How do I define the parameters from the URL to be inserted into the map and be transformed into json?
No need to use DataMapper for such a simple transformation. Instead use a MEL expression transformer to create a map out of the query parameters, then add an object-to-json-transformer to serialize this map to JSON.
For example, this creates a map with the 'name' query param in it:
<expression-transformer
expression="#[['name':message.inboundProperties.'http.query.params'.name]]" />
Just add all the params.
I have to maintain a count of messages (processing various different type of messages) that are processed in a flow. Using mule object store extension for this purpose
<objectstore:config name="storeDownLoad" doc:name="ObjectStore"/>
<objectstore:store key="countA" value-ref="3" config-ref="storeDownLoad" />
How can i add one for each key value and reassign it to object store and also how can i retrieve this value in a flowVar.
Take a look here: https://github.com/mulesoft/mule-module-objectstore/blob/master/src/test/resources/mule-config.xml
It has examples of retrieving object store values and putting them in variables. See the "retrieveVariable" flow. Alternatively you can wrap the retrieve in an enricher.