cancel
Showing results for 
Search instead for 
Did you mean: 

Read zipped base64 file and convert to xml

former_member184944
Participant
0 Kudos

Hello Experts,

I have a client requirement :

1. PI will make a soap call to ariba and receive and xml response .

2. The reponse will have base64 encoded payload.( coming in one field)

3. After decoding i will get a zip file .

4. After unzipping i will get a csv file .

5. Then i need to convert the csv file to xml .

I am trying to write java mapping code to decode base64, unzip the file and then convert the csv to xml.

However the java mapping is returning only the zip file . Can anyone please help here. Your inputs /suggestions would be great.

(PS:Unable to attach my java code)

Thanks in advance.

Anumeha.

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Anumeha

I would suggest that you split your interface into two scenarios:

Scenario 1 - Sync call and get response, decode base64 in response payload to zip content, and unzip content to csv, then directly save CSV content in a temporary file location

Scenario 2 - Pick up CSV file, perform FCC, map to target XML.

My java mapping code in the following thread will be sufficient for you to achieve the response mapping in scenario 1 - you just need to tweak the name of the element that contains the base64 value.

This would be better than having 1 java mapping to handle everything, because without actual knowledge of how the CSV structure looks like and how the target XML definition is, it is very hard to recommend sample code for it. Plus using standard FCC functionality to read the CSV is better than having to write your own mapping logic for it.

Do try out the code in the thread and if you have any further issues, do provide more details on what the issues are and we will try to assist where possible.

Rgds

Eng Swee

former_member184944
Participant
0 Kudos

Hello

thanks for your response. Your reply gave me a lead. I was able to accomplish the desired solution using Java mapping as suggested by you. I enhanced it to further read a csv file.

Regards,

Anumeha.

engswee
Active Contributor
0 Kudos

Good to hear that. If your solution is different from the one suggested, perhaps you can consider sharing it here for the benefit of others in the future, and closing this thread properly - refer to step 8b in the blog below.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello Anumeha

Can you please let me know how did u make a SOAP call to Ariba . I am trying using SOAP receiver i am not able to connect.

Please let me know how u did

Regards

Sandeep

former_member184944
Participant
0 Kudos

Hello,

In my case , Ariba provided a webservice which i could consume in PI. I used soap axis adapter to make a call.

Regards,

Anumeha.

Former Member
0 Kudos

Hello Anumeha

In my case also ariba has provided webservice but i am not able to call or connect

I tried using SOAP and HTTP adapter i was not able to succeed because need to pass Credentials through HTTP header.

can you please share or shed light on axis adapter channel config how to achieve it?

it will be of great help

Regards

sandeep

former_member184944
Participant
0 Kudos

Try referring this:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b092777b-ee47-2a10-17b3-c5f593809...

I did this in client system hence cannot  provide screen shots . However the above document should help.

former_member184944
Participant
0 Kudos

Thank you every one for your responses. I achieved the desired result using Java Mapping.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Anumeha,

                      In the same java mapping add the code to read zip files as you can see below

I am assuming resturn type of java mapping is "InputStream" class

Try use Appache.commons lib

and code as shown below

byte[] zipFileBytes;

zipFileBytes = IOUtils.toByteArray(InputStream input);

Now your Zip file is stored in a variable zipFileBytes, still in compressed form.

Then when you need to extract something use

ByteArrayInputStream bis = new ByteArrayInputStream(zipFileBytes));

ZipInputStream zis = new ZipInputStream(bis);

Then inputstream obtained needs to be converted to xml

as shown here

XML Parsing from an input stream Java - Stack Overflow

Try this, in case this does not work, need to look into your code.

Regards

Anupam

praveen_sutra
Active Contributor
0 Kudos

Hi Anumeha,

PFB the code for unzipping using java mapping.

My suggestion would be first just try to unzip a zipped file and see if java mapping for unzipping is correct.

once that is resolved go for decoding part.

hope this helps.

thanks and regards,

Praveen T