Hi Malaka,

Thanks for the suggestion and Yes, we can add to a synapse property and
then we can get that property whenever it needs.

Thanks,
Vivek

Vivekananthan Sivanayagam
Software Engineer | WSO2
E:vivekanant...@wso2.com
M:+94752786138

On Fri, Jun 9, 2017 at 9:03 AM, Malaka Silva <mal...@wso2.com> wrote:

> Why Soap header (Or even HTTP header)? Can't you add to a synapse property?
>
> On Thu, Jun 8, 2017 at 7:46 PM, Vivekananthan Sivanayagam <
> vivekanant...@wso2.com> wrote:
>
>> 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($.conten
>> tType)"/>
>>          <property name="filePattern" expression="json-eval($.filePa
>> ttern)"/>
>>          <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/trans
>> form/HeaderMediator.java
>>
>> Thanks,
>>
>> Vivekananthan Sivanayagam
>> Software Engineer | WSO2
>> E:vivekanant...@wso2.com
>> M:+94752786138 <+94%2075%20278%206138>
>>
>
>
>
> --
>
> Best Regards,
>
> Malaka Silva
> Associate Director / Architect
> M: +94 777 219 791 <+94%2077%20721%209791>
> Tel : 94 11 214 5345
> Fax :94 11 2145300
> Skype : malaka.sampath.silva
> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
> Blog : http://mrmalakasilva.blogspot.com/
>
> WSO2, Inc.
> lean . enterprise . middleware
> https://wso2.com/signature
> http://www.wso2.com/about/team/malaka-silva/
> <http://wso2.com/about/team/malaka-silva/>
> https://store.wso2.com/store/
>
> Don't make Trees rare, we should keep them with care
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to