Hi All,
I am in the process of resolving JIRA [1], here we have to show the reading
file name.To overcome this, I've added the file name in the header[2] and
get the value[3] in the proxy. I referred[4] to implement that.
[2]
public static void buildHeader(MessageContext messageContext,String
fileName) {
SOAPEnvelope env = messageContext.getEnvelope();
if (env == null) {
return;
}
SOAPFactory fac = (SOAPFactory) env.getOMFactory();
SOAPHeader header = env.getHeader();
if (header == null) {
header = fac.createSOAPHeader(env);
}
SOAPHeaderBlock hb = header.addHeaderBlock("File_Name",
fac.createOMNamespace(FileConstants.FILECON,
FileConstants.FILE_READ));
hb.setText(fileName);
}
}
[3]
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="File_Read"
transports="https http"
startOnLoad="true">
<description/>
<target>
<inSequence>
<property name="source" expression="json-eval($.source)"/>
<property name="contentType"
expression="json-eval($.contentType)"/>
<property name="filePattern"
expression="json-eval($.filePattern)"/>
<header name="FaultTo" value="http://localhost:9000"/>
<fileconnector.read>
<source>{$ctx:source}</source>
<contentType>{$ctx:contentType}</contentType>
<filePattern>{$ctx:filePattern}</filePattern>
</fileconnector.read>
<property name="fileName" expression='$header/*' scope="default"/>
<log level="custom">
<property name="FileRead, started to read "
expression="get-property('fileName')"/>
</log>
<respond/>
</inSequence>
</target>
</proxy>
Is this a correct way to achieve this functionality in File Read operation?
Give me a suggestion on above approach?
[1] https://wso2.org/jira/projects/ESBCONNECT/issues/ESBCONNECT-192
[4]
https://github.com/wso2/wso2-synapse/blob/master/modules/core/src/main/java/org/apache/synapse/mediators/transform/HeaderMediator.java
Thanks,
Vivekananthan Sivanayagam
Software Engineer | WSO2
E:[email protected]
M:+94752786138 <+94%2075%20278%206138>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev