cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion From Base-64 to Binary Format

Former Member
0 Kudos

Hi Experts,

How to convert the Base-64 format to binary for a file to proxy scenario, where input file is in the doc format.

Is there any code for the custom adaper module?

Please suggest.

Thanks,

Sushama

Accepted Solutions (1)

Accepted Solutions (1)

RKothari
Contributor
0 Kudos

Hello,

Please check the below mentioned thread:

I guess, you need to modify the java mapping code as per your requirement.

Also check the blog:

/people/farooq.farooqui3/blog/2008/05/22/decode-base64-incoming-encoded-information-in-sap-xipi-using-java-mapping

-Rahul

Edited by: Rahul Kothari on Feb 2, 2011 12:46 PM

Former Member
0 Kudos

Hi Rahul,

Thanks for the inputs.

How to convert the java mapping to an adapter module?

We dont want to use java mapping..

Please suggest.

Regards,

Sushama

RKothari
Contributor
0 Kudos

Hello,

You can use the logic in your module code, which is provided in the java mapping.

Please find below the document for creating adapter module:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0b39e65-981e-2b10-1c9c-fc3f8e674...

-Rahul

Former Member
0 Kudos

Hi Rahul,

Thanks

I have tried to create the adapter module by using the same blog,

The code isnt working it seems.

StreamTransformation is not being recognised(its error in StreamTransformation) not a valid superinterface.

Please suggest, what changes needs to be done in the code?

Reg,

Sushama

RKothari
Contributor
0 Kudos

Hello,

I guess no need to implement Stream transformation.

For Module code you only implement SessionBean and Module , as mentioned in the How To...document.

You just need to try to convert the logic mentioned in java mapping as per the Module code.

For adapter module you need to place the logic under ModuleData method.

Please refer to different module blogs:

/people/ganesh.karicharla2/blog/2008/02/20/adapter-module-development-module-configuration

/people/rinku.gangwani/blog/2008/07/16/customized-adapter-module

/people/rinku.gangwani/blog/2008/07/16/customized-sender-adapter-module

-Rahul

Former Member
0 Kudos

Hi Rahul,

Thanks.

I have changed the code. But, seems there's some problem(esp in the decoding part)

import com.sap.aii.af.mp.module.*;

import com.sap.aii.af.ra.ms.api.*;

import com.sap.aii.af.service.auditlog.*;

import com.sap.aii.af.service.cpa.BinaryData;

import java.io.PrintWriter;

import java.io.StringWriter;

import java.util.Hashtable;

import java.util.Iterator;

import javax.ejb.*;

import javax.naming.Context;

import javax.naming.InitialContext;

import sun.misc.BASE64Decoder;

import java.lang.String;

import java.nio.ByteBuffer;

public class CreateAttachmentBean

implements SessionBean

{

private SessionContext myContext;

public CreateAttachmentBean()

{

}

public void ejbRemove()

{

}

public void ejbActivate()

{

}

public void ejbPassivate()

{

}

public void setSessionContext(SessionContext context)

{

myContext = context;

}

public void ejbCreate()

throws CreateException

{

}

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

throws ModuleException

{

Object obj = null;

Message msg = null;

String msgType = null;

String nameSpace = null;

String msgDesc = null;

String FileNameSrc = null;

String contentDesc = null;

String filePath = null;

String fileName = null;

String fileType = null;

int count = 0;

Iterator it = null;

ModuleData outputModuleData = null;

Message MsgNew = null;

XMLPayload xmlpayloadNew = null;

Payload attach_msg = null;

Object objAtt_msg = null;

String attName = null;

Payload plAtt_msg = null;

AuditMessageKey amk = null;

String auditStr = "Inbound Doc";

try

{

obj = inputModuleData.getPrincipalData();

msg = (Message)obj;

msgType = moduleContext.getContextData("msgType");

nameSpace = moduleContext.getContextData("nameSpace");

FileNameSrc = moduleContext.getContextData("FileNameSrc");

Hashtable mp = (Hashtable)inputModuleData.getSupplementalData("module.parameters");

if(msg.getMessageDirection() == MessageDirection.INBOUND)

{

amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.INBOUND);

} else

{

amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.OUTBOUND);

}

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocObject created successfully");

try

{

filePath = (String)mp.get("FileName");

int lastInd = filePath.lastIndexOf("
");

lastInd++;

fileName = filePath.substring(lastInd);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocFile Name" + fileName);

}

catch(Exception e)

{

fileName = "Error in File name";

}

XMLPayload xmlpayload = msg.getDocument();

it = msg.getAttachmentIterator();

msgDesc = msg.getDescription();

String xmlDesc = null;

String xmlCont = null;

String xmlName = null;

xmlDesc = xmlpayload.getDescription();

xmlCont = xmlpayload.getContentType();

xmlName = xmlpayload.getName();

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, msgDesc + "mesg Desc");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlDesc + "xml Desc");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlCont + "xml Cont");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlName + "XML name");

if(xmlpayload != null)

{

try

{

Context ctx = new InitialContext();

ConnectionFactory cf = (ConnectionFactory)ctx.lookup("MessagingConnectionFactory");

MessageFactory factory = cf.createMessageFactory("XI");

Message msgnew = factory.createMessage(msg.getFromParty(), msg.getToParty(), msg.getFromService(), msg.getToService(), msg.getAction());

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound Doc New Message msgnew " + msgnew.getProfile());

msgnew.setConversationId(msg.getConversationId());

msgnew.setDeliverySemantics(DeliverySemantics.ExactlyOnce);

xmlpayloadNew = msgnew.createXMLPayload();

xmlpayloadNew.setContent(convertToBase64(xmlpayload, msgType, nameSpace, fileName, count, it, FileNameSrc));

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocNew Message xmlpayloadNew " + xmlpayloadNew.getName());

msgnew.setDocument(xmlpayloadNew);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocxmlpayloadNew in msgNew" + msgnew.getMessageId());

inputModuleData.setPrincipalData(msgnew);

}

catch(Exception e)

{

Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, "Inbound DocError in New Message " + ex2str(e));

}

}

}

catch(Exception exception) { }

return inputModuleData;

}

private byte[] convertToBase64(XMLPayload xmlpayload, String msgType, String nameSpace, String fileName, int count, Iterator it, String FileNameSrc)

throws Exception

{

String ContentType = null;

String ContentDesc = null;

String contentName = null;

String textData = null;

String FileMainName = null;

String encoding = null;

int startPage = 1;

int endPage = 0x7fffffff;

String retXMLData = null;

byte a[] = (byte[])null;

byte binbyt[] = (byte[])null;

String empty = null;

String Att = null;

Payload attach = null;

byte ByteAtt[] = (byte[])null;

XMLPayload xmlpayload1 = null;

String nextStr = null;

Object objAtt = null;

Payload plAtt = null;

String retAttData = null;

String finalAttData = null;

String fileNameAtt = null;

String fileTypeAtt = null;

a = xmlpayload.getContent();

ContentType = xmlpayload.getContentType();

ContentDesc = xmlpayload.getDescription();

contentName = xmlpayload.getName();

//BinaryData b = new BinaryData(a);

//textData = b.toBase64EncodedString();

BASE64Decoder decoder = new BASE64Decoder();

try

{

while(it.hasNext())

{

objAtt = it.next();

attach = (Payload)objAtt;

ByteAtt = attach.getContent();

//

//BinaryData binAttach = new BinaryData(ByteAtt);

Byte b[] = decoder.decodeBuffer(ByteAtt);

//Att = binAttach.toBase64EncodedString();

if(FileNameSrc.compareToIgnoreCase("contentType") == 0)

{

fileNameAtt = attach.getContentType();

} else

if(FileNameSrc.compareToIgnoreCase("contentDesc") == 0)

{

fileNameAtt = attach.getDescription();

}

retAttData = "<Attachment><FileName>" + fileNameAtt + "</FileName>\n" + "<FileType>" + fileTypeAtt + "</FileType>\n" + "<Base64>" + Att + "</Base64>\n" + "</Attachment>\n";

finalAttData = finalAttData + retAttData;

}

}

catch(Exception exception) { }

String FileMainType = null;

int lastInd = 0;

lastInd = fileName.lastIndexOf(".");

lastInd++;

FileMainType = fileName.substring(lastInd);

retXMLData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:" + msgType + " xmlns:ns=\"" + nameSpace + "\">\n" + "<Header>" + "<SenderID>" + empty + "</SenderID>\n" + "<SenderDetail>" + empty + "</SenderDetail>\n" + "<ReceiverID>" + empty + "</ReceiverID>\n" + "<ReceiverDetail>" + empty + "</ReceiverDetail>\n" + "<Source>" + empty + "</Source>\n" + "</Header>\n" + "<Attachment>" + "<FileName>" + fileName + "</FileName>\n" + "<FileType>" + FileMainType + "</FileType>\n" + "<Base64>" + textData + "</Base64>\n" + "</Attachment>\n" + finalAttData + "</ns:" + msgType + ">";

return retXMLData.getBytes();

}

private String ex2str(Exception e)

{

StringWriter strWr = new StringWriter();

e.printStackTrace(new PrintWriter(strWr));

return strWr.toString();

}

}

Please Suggest.

Regards,

Sushama

Former Member
0 Kudos

package com.fonterra.InboundDoc;

import com.sap.aii.af.mp.module.*;

import com.sap.aii.af.ra.ms.api.*;

import com.sap.aii.af.service.auditlog.*;

import com.sap.aii.af.service.cpa.BinaryData;

import java.io.PrintWriter;

import java.io.StringWriter;

import java.util.Hashtable;

import java.util.Iterator;

import javax.ejb.*;

import javax.naming.Context;

import javax.naming.InitialContext;

import sun.misc.BASE64Decoder;

import java.lang.String;

import java.nio.ByteBuffer;

public class CreateAttachmentBean

implements SessionBean

{

private SessionContext myContext;

public CreateAttachmentBean()

{

}

public void ejbRemove()

{

}

public void ejbActivate()

{

}

public void ejbPassivate()

{

}

public void setSessionContext(SessionContext context)

{

myContext = context;

}

public void ejbCreate()

throws CreateException

{

}

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

throws ModuleException

{

Object obj = null;

Message msg = null;

String msgType = null;

String nameSpace = null;

String msgDesc = null;

String FileNameSrc = null;

String contentDesc = null;

String filePath = null;

String fileName = null;

String fileType = null;

int count = 0;

Iterator it = null;

ModuleData outputModuleData = null;

Message MsgNew = null;

XMLPayload xmlpayloadNew = null;

Payload attach_msg = null;

Object objAtt_msg = null;

String attName = null;

Payload plAtt_msg = null;

AuditMessageKey amk = null;

String auditStr = "Inbound Doc";

try

{

obj = inputModuleData.getPrincipalData();

msg = (Message)obj;

msgType = moduleContext.getContextData("msgType");

nameSpace = moduleContext.getContextData("nameSpace");

FileNameSrc = moduleContext.getContextData("FileNameSrc");

Hashtable mp = (Hashtable)inputModuleData.getSupplementalData("module.parameters");

if(msg.getMessageDirection() == MessageDirection.INBOUND)

{

amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.INBOUND);

} else

{

amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.OUTBOUND);

}

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocObject created successfully");

try

{

filePath = (String)mp.get("FileName");

int lastInd = filePath.lastIndexOf("
");

lastInd++;

fileName = filePath.substring(lastInd);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocFile Name" + fileName);

}

catch(Exception e)

{

fileName = "Error in File name";

}

XMLPayload xmlpayload = msg.getDocument();

it = msg.getAttachmentIterator();

msgDesc = msg.getDescription();

String xmlDesc = null;

String xmlCont = null;

String xmlName = null;

xmlDesc = xmlpayload.getDescription();

xmlCont = xmlpayload.getContentType();

xmlName = xmlpayload.getName();

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, msgDesc + "mesg Desc");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlDesc + "xml Desc");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlCont + "xml Cont");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlName + "XML name");

if(xmlpayload != null)

{

try

{

Context ctx = new InitialContext();

ConnectionFactory cf = (ConnectionFactory)ctx.lookup("MessagingConnectionFactory");

MessageFactory factory = cf.createMessageFactory("XI");

Message msgnew = factory.createMessage(msg.getFromParty(), msg.getToParty(), msg.getFromService(), msg.getToService(), msg.getAction());

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound Doc New Message msgnew " + msgnew.getProfile());

msgnew.setConversationId(msg.getConversationId());

msgnew.setDeliverySemantics(DeliverySemantics.ExactlyOnce);

xmlpayloadNew = msgnew.createXMLPayload();

xmlpayloadNew.setContent(convertToBase64(xmlpayload, msgType, nameSpace, fileName, count, it, FileNameSrc));

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocNew Message xmlpayloadNew " + xmlpayloadNew.getName());

msgnew.setDocument(xmlpayloadNew);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocxmlpayloadNew in msgNew" + msgnew.getMessageId());

inputModuleData.setPrincipalData(msgnew);

}

catch(Exception e)

{

Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, "Inbound DocError in New Message " + ex2str(e));

}

}

}

catch(Exception exception) { }

return inputModuleData;

}

private byte[] convertToBase64(XMLPayload xmlpayload, String msgType, String nameSpace, String fileName, int count, Iterator it, String FileNameSrc)

throws Exception

{

String ContentType = null;

String ContentDesc = null;

String contentName = null;

String textData = null;

String FileMainName = null;

String encoding = null;

int startPage = 1;

int endPage = 0x7fffffff;

String retXMLData = null;

byte a[] = (byte[])null;

byte binbyt[] = (byte[])null;

String empty = null;

String Att = null;

Payload attach = null;

byte ByteAtt[] = (byte[])null;

XMLPayload xmlpayload1 = null;

String nextStr = null;

Object objAtt = null;

Payload plAtt = null;

String retAttData = null;

String finalAttData = null;

String fileNameAtt = null;

String fileTypeAtt = null;

a = xmlpayload.getContent();

ContentType = xmlpayload.getContentType();

ContentDesc = xmlpayload.getDescription();

contentName = xmlpayload.getName();

//BinaryData b = new BinaryData(a);

//textData = b.toBase64EncodedString();

BASE64Decoder decoder = new BASE64Decoder();

try

{

while(it.hasNext())

{

objAtt = it.next();

attach = (Payload)objAtt;

ByteAtt = attach.getContent();

//

//BinaryData binAttach = new BinaryData(ByteAtt);

Byte b[] = decoder.decodeBuffer(ByteAtt);

//Att = binAttach.toBase64EncodedString();

if(FileNameSrc.compareToIgnoreCase("contentType") == 0)

{

fileNameAtt = attach.getContentType();

} else

if(FileNameSrc.compareToIgnoreCase("contentDesc") == 0)

{

fileNameAtt = attach.getDescription();

}

retAttData = "<Attachment><FileName>" + fileNameAtt + "</FileName>\n" + "<FileType>" + fileTypeAtt + "</FileType>\n" + "<Base64>" + Att + "</Base64>\n" + "</Attachment>\n";

finalAttData = finalAttData + retAttData;

}

}

catch(Exception exception) { }

String FileMainType = null;

int lastInd = 0;

lastInd = fileName.lastIndexOf(".");

lastInd++;

FileMainType = fileName.substring(lastInd);

retXMLData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:" + msgType + " xmlns:ns=\"" + nameSpace + "\">\n" + "<Header>" + "<SenderID>" + empty + "</SenderID>\n" + "<SenderDetail>" + empty + "</SenderDetail>\n" + "<ReceiverID>" + empty + "</ReceiverID>\n" + "<ReceiverDetail>" + empty + "</ReceiverDetail>\n" + "<Source>" + empty + "</Source>\n" + "</Header>\n" + "<Attachment>" + "<FileName>" + fileName + "</FileName>\n" + "<FileType>" + FileMainType + "</FileType>\n" + "<Base64>" + textData + "</Base64>\n" + "</Attachment>\n" + finalAttData + "</ns:" + msgType + ">";

return retXMLData.getBytes();

}

private String ex2str(Exception e)

{

StringWriter strWr = new StringWriter();

e.printStackTrace(new PrintWriter(strWr));

return strWr.toString();

}

}

Former Member
0 Kudos

package com.fonterra.InboundDoc;

import com.sap.aii.af.mp.module.*;

import com.sap.aii.af.ra.ms.api.*;

import com.sap.aii.af.service.auditlog.*;

import com.sap.aii.af.service.cpa.BinaryData;

import java.io.PrintWriter;

import java.io.StringWriter;

import java.util.Hashtable;

import java.util.Iterator;

import javax.ejb.*;

import javax.naming.Context;

import javax.naming.InitialContext;

public class CreateAttachmentBean

implements SessionBean

{

private SessionContext myContext;

public CreateAttachmentBean()

{

}

public void ejbRemove()

{

}

public void ejbActivate()

{

}

public void ejbPassivate()

{

}

public void setSessionContext(SessionContext context)

{

myContext = context;

}

public void ejbCreate()

throws CreateException

{

}

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

throws ModuleException

{

Object obj = null;

Message msg = null;

String msgType = null;

String nameSpace = null;

String msgDesc = null;

String FileNameSrc = null;

String contentDesc = null;

String filePath = null;

String fileName = null;

String fileType = null;

int count = 0;

Iterator it = null;

ModuleData outputModuleData = null;

Message MsgNew = null;

XMLPayload xmlpayloadNew = null;

Payload attach_msg = null;

Object objAtt_msg = null;

String attName = null;

Payload plAtt_msg = null;

AuditMessageKey amk = null;

String auditStr = "Inbound Doc";

try

{

obj = inputModuleData.getPrincipalData();

msg = (Message)obj;

msgType = moduleContext.getContextData("msgType");

nameSpace = moduleContext.getContextData("nameSpace");

FileNameSrc = moduleContext.getContextData("FileNameSrc");

Hashtable mp = (Hashtable)inputModuleData.getSupplementalData("module.parameters");

if(msg.getMessageDirection() == MessageDirection.INBOUND)

{

amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.INBOUND);

} else

{

amk = new AuditMessageKey(msg.getMessageId(), AuditDirection.OUTBOUND);

}

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocObject created successfully");

try

{

filePath = (String)mp.get("FileName");

int lastInd = filePath.lastIndexOf("
");

lastInd++;

fileName = filePath.substring(lastInd);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocFile Name" + fileName);

}

catch(Exception e)

{

fileName = "Error in File name";

}

XMLPayload xmlpayload = msg.getDocument();

it = msg.getAttachmentIterator();

msgDesc = msg.getDescription();

String xmlDesc = null;

String xmlCont = null;

String xmlName = null;

xmlDesc = xmlpayload.getDescription();

xmlCont = xmlpayload.getContentType();

xmlName = xmlpayload.getName();

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, msgDesc + "mesg Desc");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlDesc + "xml Desc");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlCont + "xml Cont");

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, xmlName + "XML name");

if(xmlpayload != null)

{

try

{

Context ctx = new InitialContext();

ConnectionFactory cf = (ConnectionFactory)ctx.lookup("MessagingConnectionFactory");

MessageFactory factory = cf.createMessageFactory("XI");

Message msgnew = factory.createMessage(msg.getFromParty(), msg.getToParty(), msg.getFromService(), msg.getToService(), msg.getAction());

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound Doc New Message msgnew " + msgnew.getProfile());

msgnew.setConversationId(msg.getConversationId());

msgnew.setDeliverySemantics(DeliverySemantics.ExactlyOnce);

xmlpayloadNew = msgnew.createXMLPayload();

xmlpayloadNew.setContent(convertToBase64(xmlpayload, msgType, nameSpace, fileName, count, it, FileNameSrc));

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocNew Message xmlpayloadNew " + xmlpayloadNew.getName());

msgnew.setDocument(xmlpayloadNew);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Inbound DocxmlpayloadNew in msgNew" + msgnew.getMessageId());

inputModuleData.setPrincipalData(msgnew);

}

catch(Exception e)

{

Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, "Inbound DocError in New Message " + ex2str(e));

}

}

}

catch(Exception exception) { }

return inputModuleData;

}

private byte[] convertToBase64(XMLPayload xmlpayload, String msgType, String nameSpace, String fileName, int count, Iterator it, String FileNameSrc)

throws Exception

{

String ContentType = null;

String ContentDesc = null;

String contentName = null;

String textData = null;

String FileMainName = null;

String encoding = null;

int startPage = 1;

int endPage = 0x7fffffff;

String retXMLData = null;

byte a[] = (byte[])null;

byte binbyt[] = (byte[])null;

String empty = null;

String Att = null;

Payload attach = null;

byte ByteAtt[] = (byte[])null;

XMLPayload xmlpayload1 = null;

String nextStr = null;

Object objAtt = null;

Payload plAtt = null;

String retAttData = null;

String finalAttData = null;

String fileNameAtt = null;

String fileTypeAtt = null;

a = xmlpayload.getContent();

ContentType = xmlpayload.getContentType();

ContentDesc = xmlpayload.getDescription();

contentName = xmlpayload.getName();

BinaryData b = new BinaryData(a);

textData = b.toBase64EncodedString();

try

{

while(it.hasNext())

{

objAtt = it.next();

attach = (Payload)objAtt;

ByteAtt = attach.getContent();

BinaryData binAttach = new BinaryData(ByteAtt);

Att = binAttach.toBase64EncodedString();

if(FileNameSrc.compareToIgnoreCase("contentType") == 0)

{

fileNameAtt = attach.getContentType();

} else

if(FileNameSrc.compareToIgnoreCase("contentDesc") == 0)

{

fileNameAtt = attach.getDescription();

}

retAttData = "<Attachment><FileName>" + fileNameAtt + "</FileName>\n" + "<FileType>" + fileTypeAtt + "</FileType>\n" + "<Base64>" + Att + "</Base64>\n" + "</Attachment>\n";

finalAttData = finalAttData + retAttData;

}

}

catch(Exception exception) { }

String FileMainType = null;

int lastInd = 0;

lastInd = fileName.lastIndexOf(".");

lastInd++;

FileMainType = fileName.substring(lastInd);

retXMLData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:" + msgType + " xmlns:ns=\"" + nameSpace + "\">\n" + "<Header>" + "<SenderID>" + empty + "</SenderID>\n" + "<SenderDetail>" + empty + "</SenderDetail>\n" + "<ReceiverID>" + empty + "</ReceiverID>\n" + "<ReceiverDetail>" + empty + "</ReceiverDetail>\n" + "<Source>" + empty + "</Source>\n" + "</Header>\n" + "<Attachment>" + "<FileName>" + fileName + "</FileName>\n" + "<FileType>" + FileMainType + "</FileType>\n" + "<Base64>" + textData + "</Base64>\n" + "</Attachment>\n" + finalAttData + "</ns:" + msgType + ">";

return retXMLData.getBytes();

}

private String ex2str(Exception e)

{

StringWriter strWr = new StringWriter();

e.printStackTrace(new PrintWriter(strWr));

return strWr.toString();

}

}

RKothari
Contributor
0 Kudos

Hello,

Could you be more elaborative on the kind of error or issue you are facing.

You try to use the other api: com.sap.aii.utilxi.base64.api.*; in your module code.

-Rahul

Former Member
0 Kudos

Hi,

It is giving error while decoding..typecast error.

Not sure which decoding method to be used..

Please suggest.

Thanks,

Sushama

stefan_grube
Active Contributor
0 Kudos

Here an interesting blog:

/people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi

Have you thought about doing the base64 conversion in ABAP?

For example with FM SSFC_BASE64_DECODE and SSFC_BASE64_ENCODE

Former Member
0 Kudos

Hi Stefan,

Thanks for the inputs.

Regarding the thread:

The thread is for file to file scenario, whereas I am using file to proxy scenario. Moreover, the module for binary to base 64 encryption is already written(pasted earlier post). So I was thinking to modify the same code.But no luck so far ..

Secondly, using ABAP..did u mean by abap mapping?

How will i use the program.i suppose in mapping?

Please suggest.

Regards,

Sushama

stefan_grube
Active Contributor
0 Kudos

> The thread is for file to file scenario, whereas I am using file to proxy scenario.

I do not get this. What is your scenario actually?

> Secondly, using ABAP..did u mean by abap mapping?

In ABAP proxy, of course this is only possible when you have an ABAP proxy.

Former Member
0 Kudos

Hi Stefan,

My scenario is file to proxy, where the binary is encoded in Base 64 and getting attached to GTS.

Yes we do hav abap proxy.

Do I need to call the function module in the abap program?

Please check if anything wrong in the code?

Please suggest,

Thanks,

Sushma

Answers (0)