Quantcast
Channel: SCN : Blog List - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 676

Character Encoding Handled the right way

$
0
0

In our daily business we have to handle different types of data-sources and data-sinks. Most of these data-source and data-sinks are UTF-8 aware already. But what if one of these is does not provide data in UTF-8 or does not understand it at all?

 

The PI/PO is only handling UTF-8-Data so how is it possible within the PI to convert the Encoding of a File/Message?

 

In one of our current scenarios we have to handle fixed-length files, which are read from a SFTP server.

(But this guide should also be valid for other scenarios)

 

The configuration is simple, but not obvious since the behaviour of the MessageTransformBean is a little bit strange

 

Here is what you have to do in the Module-Chain of your channel if you want to convert a message from a supported encoding into UTF-8.

 

Processing Sequence

NumberModule NameTypeModule Key
1AF_Modules/MessageTransformBeanLocal Enterprise BeanCodepage
2AF_Modules/TextCodepageConversionBeanLocal Enterprise BeanConvert
3AF_Modules/MessageTransformBeanLocal Enterprise BeanTransform
4localejbs/CallSapAdapterLocal Enterprise Beanentry

 

Module Configuration

Module KeyParameter NameParameter Value
CodepageTransform.ContentTypetext/plain;charset=ISO-8859-1
ConvertConversion.charsetutf-8
TransformTransform.Classcom.sap.aii.messaging.adapter.Conversion
Transformxml.conversionTypeSimplePlain2XML
Transformxml.documentNameFoo
Transformxml.documentNamespacehttp://example.com
Transformxml.fieldFixedLength1,2,3
Transformxml.fieldNamesID, Bar, Baz
Transformxml.processFieldNamesfromConfiguration
Transformxml.structureTitleBar

 

The key in this configuration is to use two different instance of the MessageTransformBean. The first one only sets the codepage, and mime-type, which is then converted by the TextCodepageConversionBean. The sencond one parses the (now utf-8) text into xml.

 

These two steps are necessary since the class "com.sap.aii.messaging.adapter.Conversion" expects its data as utf-8 which is not right if the incomming codepage is not utf-8 but an other one.


Viewing all articles
Browse latest Browse all 676

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>