using variable in transfer tag in vxml - vxml

I am writing a VXML script to execute a Bridge transfer.
This is how it looks-
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml" version="2.0" >
<form id="F1">
<transfer aai="name:Caller1; ANI:94100; myAaiCDATA" name="T_1" bridge="true" dest="sip:5060#10.130.140.38" >
<prompt>
Placing the call
</prompt>
</transfer>
</form>
</vxml>
It completes the transfer successfully.
Now, instead of passing hard-coded values for aai name, ANI, I want to pass on variables.
For e.g.- I want to pass transfer dest value from a variable.
How can I do that?
Your help is greatly appreciated.

Per the specification, you can set the aii and dest values dynamically with aiiexpr and destexpr. With these attributes, the value is treated as an ECMAScript expression that is executed with the result value being used.

Related

Anypoint Studio console execution does not go past deployed

Below is the configuration xml of my small program in Anypoint Studio. What i am trying to do is copying one text file data(pipe delimited) to another text file. The execution goes well but stops at status as "Deployed". I have tried other transformations as well but the result is same. Help is highly appreciable. Thanks in advance.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
<flow name="texttoexcelFlow" doc:id="42aaa83a-e26a-4f6d-8d2f-da3613a8d232" initialState="started">
<file:read doc:name="Read" doc:id="89fa46c9-aa14-4a79-b7ab-e609b9fad501" path="D:\Mulesoft Input\Name.txt" outputMimeType="application/json" outputEncoding="UTF-8">
<repeatable-in-memory-stream />
</file:read>
<ee:transform doc:name="Transform Message" doc:id="86dc86b8-99ed-4bee-b5bc-e07616e44431" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/csv headerLineNumber = 0 , header = false , separator = "|"
---
payload map ( payload01 , indexOfPayload01 ) -> {
FirstName: payload01.FirstName ,
LastName: payload01.LastName
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<file:write doc:name="Write" doc:id="3884725e-3870-4ef1-9e05-b10a2274dfa6" path="C:\Users\aseem\Desktop\Mulesoft Output\Excel.txt">
</file:write>
</flow>
</mule>
"
You need something to trigger the flow to run. file:read doesn’t do this automatically.
All flows need a ‘Source’ to trigger them unless you are calling them from other flows using flow-ref (or from dataweave using a lookup()).
If you know the exact file you want then you can put a scheduler before your file:read to trigger the flow:
<scheduler>
<scheduling-strategy>
<fixed-frequency startDelay="5" frequency="10" timeUnit="SECONDS"/>
</scheduling-strategy>
</scheduler>
Or you can use a file:listener to listen for new files in a directory etc as the source directly:
<flow name="onNewFile">
<file:listener config-ref="file" directory="test-data/in" autoDelete="true">
<scheduling-strategy>
<fixed-frequency frequency="1000"/>
</scheduling-strategy>
</file:listener>
...
</flow>
You can use fixed frequency or cron. More details here: https://docs.mulesoft.com/mule-runtime/4.1/scheduler-xml-reference

How to get file uploaded time in wso2 esb sequence

I am using WSO2 inbound endpoint to fetch a file from an FTP server. And I know how to get the file name back. Now my question is how to get the file uploaded time back (or the last modified time)?
This is the code to get the file name.
<property expression="get-property('transport', 'FILE_NAME')" name="ftp.var.filename"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ns2="http://org.apache.synapse/xsd"/>
I think there should be a similar code to get the timestamp of the file.
With the following property, you will be able to get the last modified time of the file polled from the inbound endpoint.
`<property expression="get-property('transport', 'LAST_MODIFIED')" name="ftp.var.last.modified.time" xmlns:ns="http://org.apache.synapse/xsd"/>`
Add this to the relevant sequence to further process and following is a sample sequence in which the file name and the last modified time is logged.
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="fileSequence" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property expression="get-property('transport', 'FILE_NAME')"
name="ftp.var.filename" xmlns:ns="http://org.apache.synapse/xsd"/>
<property
expression="get-property('transport', 'LAST_MODIFIED')"
name="ftp.var.last.modified.time" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
</sequence>
Please check whether this meets your requirement and please refer [1] to further clarify this.
[1]-https://github.com/wso2/wso2-synapse/blob/master/modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSTransportListener.java#L767

Is it possible to get file name while reading a file using WSO2 ESB File Connector 2

I am doing a simple file read using WSO2 ESB File connection 2. I try to read a .OUT file from the given directory. It reads the first file (alphabetical order?) well but I have no idea which file is read. Is there a (transport?) property that gets populated when a file is read?
Here is my code in a proxy service
<fileconnector.read>
<source>file:///D:/temp</source>
<filePattern>.*\.OUT</filePattern>
<contentType>text/plain</contentType>
</fileconnector.read>
<log level="full"/>
I get the following response
INFO - LogMediator To: /services/SampleProxy.SampleProxyHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:f5737693-6a51-4044-9134-95cd61eaeaa4, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><text xmlns="http://ws.apache.org/commons/ns/payload">abc,123
qwe,456
</text></soapenv:Body></soapenv:Envelope>
Give it a try like this. (Just a suggestion. I didn't try.)
<log level="custom">
<property name="FileName" expression="$trp:FILE_NAME" />
</log>
If you want to read a particular file, you can pass the full path as a value in source and you can skip the file pattern value.
<fileconnector.read>
<source>file:///D:/temp/abc.OUT</source>
<filePattern></filePattern>
<contentType>text/plain</contentType>
</fileconnector.read>
This is a valid requirement. We will consider this in our future release. Please use [1] to track the progress.
[1] https://wso2.org/jira/browse/ESBCONNECT-192

JSF 1.2 JSP 2.0 Simple Custom Tag File with Attributes

So I'm trying to do a custom tag in a JSF 1.2 environment with JSP 2.0. I'm ultimately trying to pass a java Object as an attribute with EL, but I was getting a "org.apache.jasper.JasperException: jsp.error.beans.property.conversion" exception. So I took a step back and tried to just get a simple custom tag to work. I was successful in printing hello world. I then tried to pass it a simple String attribute and just print that. This was not working. The attribute would not print to the screen. The static "hello world" text does just not the attribute.
WEB-INF/tags/helloworld.tag:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.attribute name="message" required="true"/>
<ui:staticText id="asdf" text="hello world: #{message}"/>
</jsp:root>
MyBean.jsp then defines the tag namespace: xmlns:tags="urn:jsptagdir:/WEB-INF/tags" and then calls the tag like so:
<tags:helloworld message="Test message"/>
I am using jboss 4.0.4 to deploy the war file.
Try to set rtexprvalue="true" in "message" attribute ie:
<jsp:directive.attribute name="message" required="true" rtexprvalue="true"/>

defining array variable in web-harvest

I'm using Web-Harvest to extract some data from a site.
Site gets a POST variable named Code and gives data according to it.
The available codes are gathered from another page of that site.
How Can I define an array like variable to store those data that are related to a Code in a array like variable that make me able to retrieve them with a loop in main program?
I mean something like this:
Data[code1]={key1=val1, key2=val2, key3=val3,...}
Data[code2]={key1=val1, key2=val2, key3=val3,...}
Data[code3]={key1=val1, key2=val2, key3=val3,...}
Data[code4]={key1=val1, key2=val2, key3=val3,...}
...
You can use <script> tag and build an array inside it using BeanShell, Groovy or JavaScript. Default is BeanShell.
Then expose it to your script with SetContextVar() method or return attribute of the <script>.
Below is example that builds an array of strings codes and then iterates through them with <loop>.
<?xml version="1.0" encoding="UTF-8"?>
<config>
<script><![CDATA[
String[] codes = new String[] {"one", "two", "three"};
SetContextVar("codes", codes);
]]></script>
<loop item="code">
<list>
<var name="codes" />
</list>
<body>
<var name="code" />
</body>
</loop>
</config>
Read more about <script> in the Web-Harvest manual.

Resources