How to Read specific column value from .text file in wso2 esb - wso2-esb

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.

Related

Using template message body on WCF-SQL adapter in Biztalk to insert promoted properties into SQL database

I need to insert some data from an XML document into an SQL table using a stored procedure. This should be done using the WCF-SQL adapter on a send port in Biztalk. I've set up the connection properties on the adapter, but I am missing the message part.
I'm currently using the below code with some hardcoded values inside a body template:
<SaveDocument xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo">
<conversationID>123456</conversationID>
<dataType>OIO</dataType>
<fromID></fromID>
<toID></toID>
<msgInfoExtension><![CDATA[<infoExt><fileInfo fileName="ublinvoice.xml" encoding="utf-8" /></infoExt>]]></msgInfoExtension>
<msgBody>
<bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="string"/>
</msgBody>
<msgBodyBin></msgBodyBin>
</SaveDocument>
Instead of the hardcoded values, I need to grab some of the promoted properties in an XML document, but I'm unsure how to correctly go about doing this.
In the MS documentation I found this page, which describes the structure of the request: https://learn.microsoft.com/en-us/biztalk/adapters-and-accelerators/adapter-sql/message-schemas-for-procedures-and-functions
Distinguish the properties that you want to set in the SaveDocument schema
Create a map that populates the fields, the ones you want to set from the Promoted properties, just fill them with some constants from the map.
In an Orchestration have a Construct Message that contains both the map shape pointing to the above map and a message assignment shape.
In the message assignment shape have some statements like saveSG.conversationID = sourceMSG(PropmotedProperty).
P.S. I think you have manually tried to create the SaveDocument schema. This is probably not correct. The correct way is to create the stored procedure and then use the Generate Instance dialogue in Visual Studio, and to configure that to auto generate the schema for you, and as a bonus, it even generates a binding file containing the settings you need for your send port.
You might be able to use the often overlook Property Demotion feature.
It's basically the reverse of Promotion and is done by the XmlAssembler component.

Jmeter : Number of active threads

I am using jmeter in elemetery freya (14.04)
I have a jmeter test plan with view results tree
I am trying to generate a csv file in view results tree including the number of active threads field.
It appears to me that the detail is being entered in the result.csv file, but the values representing this attribute has no field name, and hence that detail cannot be used in a graph which I want to create from the result.csv
I have changed JMETER-INSTALL-DIR/bin/jmeter.properties according to https://jmeter-plugins.org/wiki/PluginInstall/#Configure-JMeter
How can I get a result.csv file with a suitable fieldname like "active-threads"
Don't change anything in jmeter.properties file, upgrade to new JMeter version will discard your changes. Use user.properties file instead
The in order to add column names to CSV file add the following property to user.properties file:
jmeter.save.saveservice.print_field_names=true
Assuming good configuration you should be seeing grpThreads and allThreads columns along with the values.
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of working with them

Conditionally, Converting of JSON to XML using MuleSoft

I have a simple conversion of JSON to XML using MuleSoft. In "Transform Message" component, I provided JSON Schema as Input and XML Schema as Output. When I run the app, the conversion happens if the file matches with both schema but it generates an empty XML file if it doesn't match.
I want below conditions:
1) If the file matches with schema, the converted output file should be sent to converted folder and the original file should move to Success folder.
2) If the file doesn't match with schema, the original file should move to the Failure folder instead of conversion.
Hope, I explained it comprehensively as I am new to MuleSoft. Here is a sample diagram which may simplify my requirement. Provide me with a new one if I badly designed the process.
First thing you need to create a flowVar that will hold your original payload.
When your doing your evaluation, if its XML then use a simple XPath expression like //elementName[not(node())]
Lastly, on your success use scatter-gather for multi-threading write. Pull your original payload from flowVar and write to Success and Write your regular payload to your Converted folder

Dataweave transformation for input variable to soap header

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'.

Mule Datamapper values from property file

I have use case as below
In mule flow i have configured a data mapper with source to target of types XML. At target side i have some header values which should contain username and password values.
I want to read the username and password values from properties file under src/main/resources.
Using normal MEL expression ${user},${password} is not working. Can some one help on this issue.
Pass these property values as input arguments to DataMapper, as explained here: https://stackoverflow.com/a/22248164/387927