on 03-23-2011 5:13 AM
Hi all,
I am trying to add some attachment to payload using JAVA Mapping.
*********************************************************************
public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException
{
try{
System.out.println("JAVA Mapping is Initiated");
//getTrace().addInfo("JAVA Mapping HMAC is Initiated");
InputStream stream1 = arg0.getInputPayload().getInputStream();
String inputPayload = convertInputStreamToString(stream1);
System.out.println("input file "+inputPayload);
String outputPayload = "";
outputPayload = inputPayload;
byte[] b = inputPayload.getBytes();
System.out.println("JAVA Mapping "+b.length);
try{
*OutputAttachments outputAttachments = arg1.getOutputAttachments();
Attachment attachments = outputAttachments.create("sd", b); *
outputAttachments.setAttachment(attachments);
} catch (Exception e)
{//getTrace().addInfo("JAVA Mapping Trace "+e);
System.out.println("test "+e);}
arg1.getOutputPayload().getOutputStream().write(outputPayload.getBytes("UTF-8"));
} catch (Exception e)
{System.out.println(e.getStackTrace());}
}
**********************************************************************************************************
I am getting null pointer exception from below line
*Attachment attachments = outputAttachments.create("sd", b); *
feels like
outputAttachments = arg1.getOutputAttachments(); is returning null.
Please help me in solving same
Regards
Pradeep
Hi Pradeep,
Ref: /people/stefan.grube/blog/2007/04/17/xi-mail-adapter-an-approach-for-sending-emails-with-attachment-with-help-of-java-mapping - An approach for sending emails with attachment with help of Java mapping
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you checked "read attachments" in operation mappings?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please check the below mentioned link
http://wiki.sdn.sap.com/wiki/display/XI/SampleJAVAMappingcodeusingPI7.1+API
Thanks
Suma
Have you tried working with the addAttachment() method of the Message interface (http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/engine/interfaces/messaging/api/Message.html#addAttachment%28com.sap.engine.interfaces.messaging.api.Payload%29) ... It may require some (major) redesign of your JAVA mapping (I'm still on XI, so I can't validate this assumption)
Chris
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.