Skip to Content
avatar image
Former Member

Read zipped Base64-Stream and convert it to xml

Hello exprts,

I'm currently working on an interface where I have to read a zip-file from a webservice. This zp files ist base64-encoded and contains an xml-list that I need to populate to the target structure. I got the scenario so far, that it is working in the eclipse enviroment as clean java code. There I can decode the base64-string, uzipp the archive and save the inherit xml-file on my filesystem.

But I don't get it working as java mapping in a udf. I don't know how to convert the (unzipped) bytesream in order to return the xml file to the repsonse structure. Currently I'm only haveing the zip-entry as outputstream:

Does anyone of you has a sugesstion on how to get xml file in the zip-archive as output of the mapping?

regards

Christian

Clipboard01.jpg (56.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 30, 2014 at 09:02 AM

    Hi Christian,

    I'm afraid this cannot be tested at all using test tab in ESR. You need to do an end-to-end testing to confirm if your scenario is working or at least make it in the request message mapping pipeline in sxi_monitor.

    As far as I know, for FileOutputStream, you need to set the path to a directory in AL11 e.g

    FileOutputStream fout = new FileOutputStream("/tmp/"+ze.getName());

    Hope this helps,

    Mark

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Eng Swee Yeoh

      Hello Eng Swee Yeoh,

      I have a similar urgetn requirement in my current project , where i have to read zipped base64,  csv file and convert it to xml .

      Can you please help me with the java mapping code where after unzipping you get a csv file and then convert the csv file to xml .

      Thanks in advance.

  • Oct 30, 2014 at 08:43 AM

    Hi Christian

    Just to confirm - is your input payload already in the zipped format? If so, how do you convert it to a String to feed to your zipBase64 parameter of your UDF (which is expecting a String input)?

    For your scenario, it would probably be better to handle it entirely as a Java mapping. You can either Write Java Mapping directly in ESR! or develop it directly in your Eclipse IDE. You will need to have a class to extend the AbstractTransformation class and override the transform(TransformationInput input, TransformationOutput output) method.

    You can get the InputStream by using the following code, followed by your logic to decode/unzip, etc.

    InputStream is = input.getInputPayload().getInputStream();

    Is the unzipped and decoded content already in XML format that you expect? If yes, then you can just directly write it to the output stream. If not, then you can further parse the content and build the XML output yourself (either using DOM or String processing.)

    Regardless of either way you develop, you can still test it in ESR using the technique below which allows you to enter the binary zip file as the source.

    Can we test Binary Files in Interface/Operation Mapping???

    Rgds

    Eng Swee

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Christian,

      Just need to clarify this part, to determine if you need Java mapping or UDF in Message mapping.

      The bytestream is in the return value of the response structure as a tag. I just pass this value to the udf.

      If your input format is already zipped/encoded, how is it passed as a String to the UDF? I still can't visualize your input. In order to pass a value as a parameter into a UDF, the source structure has to be in XML format.

      Is your input an XML file with one of the fields having an embedded base64 value?

      Rgds

      Eng Swee