mzwebstudio
mzwebstudio

Reputation: 42

WSO2 ESB Writing XML file with xml tag

I have converted an xml file to another xml using xslt mediator then I I write the file using vfs to create .xml file, everything seems to work fine. But I want to add the following tag in the beginning of the file:

<?xml version="1.0" encoding="UTF-8"?>

I have tried using this property:

<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>

It adds soap envelope to file as well which is not required.

Any suggestions? I am using esb 4.8.0

Upvotes: 1

Views: 1220

Answers (3)

Navaneeth
Navaneeth

Reputation: 51

xml file i try to transfer from local system to SFTP folder. XML file was transfered but xml file doesn't having xml encoding() bacause that encoding tag removed by wso2esb4.8.1. So i am used below option to keep xml encoding tag.

parameter name="transport.vfs.FileNamePattern as (..)

parameter name="transport.vfs.ContentType" as (text/plain)

Change these lines in your Proxy file. It is working for me.

Upvotes: 1

krishan
krishan

Reputation: 579

When sending a message out from the ESB, a message formatter is used to build the outgoing stream. The message formatter is selected based on the message's content type.

If you want to transform messages to XML, you could add the following messageType property before the send mediator in the configuration.

<property name="messageType" value="application/xml" scope="axis2"/>

When adding messageType property with value="text/xml" then SOAP Formatter will use to build your outgoing stream ("org.apache.axis2.builder.SOAPBuilder"). That is why you have seen a SOAP Envelope as the result.

More info - Working with Message Builders and Formatters

Upvotes: 0

Jean-Michel
Jean-Michel

Reputation: 5946

Use a different mime type (i.e. application/xml):

<property name="messageType" value="application/xml" scope="axis2" type="STRING"/>

Upvotes: 0

Related Questions