oracle-databasedataweavemule4xmltype

How to enforce a encoding format when writing XML into Oracle Table in Mule 4?


When i was writing an XML into Oracle Table (column type as XMLTYPE ) its writing without showing any encoding type . This is a current process achieving through Java . We are migrating this process to Mule . In Mule the xml is writing into same table but after writing i see encoding format in that XML . Not sure how its coming , its not there actual xml .

XML in Table when inserting using Java

<?xml version="1.0"?>

When Using Mule

<?xml version="1.0" encoding="US-ASCII"?>

The Code using in Mule to insert XML is below

'REQUEST_XML' : write(payload, 'application/xml'),

This is my insert statement

insert into xmlpkg.REQ_RESP (ID, REQUEST_XML) values (xmlpkg.SEQ_DV.nextval,   
:REQUEST_XML  )

I giving below in my Input Parameters

{
'REQUEST_XML'  : write(payload, 'application/xml')
}

My Payload is an xml but it will come as text , i cannot change it.

<DRIVERequest Version="1.00">
<Authentication PortalID="*****" Password="*******" Username="*******"/>
</DRIVERequest>

enter image description here

This is what i am seeing in log just before the insert operation

Before DB operation : "<?xml version='1.0' encoding='UTF-8'?>\n<DRIVERequest 
Version=\"1.00\">\n  <Authentication PortalID=\"*****\" Password=\"*******\" 
Username=\"*******\"/>\n</DRIVERequest>"

My transformation is

%dw 2.0
output application/json
---
{
requestXML : write(payload, 'application/xml')
}

In Input Arguments i am taking it as below

{
'REQUEST_XML': payload.requestXML
}

In the log i am seeing as UTF-8 but after insert operation its showing as encoding="US-ASCII"


Solution

  • It looks to be that it is not Mule but the Oracle JDBC driver is picking up the wrong encoding somewhere.

    Possible solutions:

    1. Ensure that you are using a recent JDBC driver.
    2. Search for any environment variable in your operating system that could be setting the wrong encoding. For example NLS_LANG (see https://community.oracle.com/tech/developers/discussion/974099/encoding-changed-after-updatexml)
    3. Alternatively, try to set NLS_LANG explicitly to avoid any incorrect defaults.
    4. Finally read Oracle documentation for other similar configurations that might affect the driver.