Skip to Content
avatar image
Former Member

PI 7.1 Email Attachment binary file

Hi,

I am trying to attach a binary (encrypted) file to a regular mapped email (receiver adapter) before sending it.

It is similiar to attach pdf-files at the end of a mapping process.

Is there no way to attach binary files other than writing an adapter module?

Is there no generic "Attach File" module in PI 7.11?

I tried ASMA with XSLT, but the problem is, that the file is binary and the sender adapter would not read it without xml-format.

Any good idea?

thanks

hs

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Feb 24, 2010 at 04:28 PM

    no standard module available.

    you can either use the new mapping api and create your own attachments in PI 7.1 or else create a adapter module to help you out

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 25, 2010 at 09:03 AM

    Hi Suraj,

    this sounds very promising.

    My problem is:

    TheFile is binary.

    Therefore, The Sender File Adapter does not recognize a valid schema/XML.

    If there is no valid XML/Schema, I will not be able to assign an operational Mapping.

    (Receiver Determination will not work for interfaces without valid Service Interface)

    How Do I work around this fact?

    Thanks

    Holger

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Holger Stumm

      Hi Holger,

      Check the following:

      1 The log for sender file adapter. Is it success?

      2. Which step in MONI is showing this error?

      3. Check the Main section of SOAP Header in SXMB_MONI message, is it showing the correct value for sender party/sevrice, interface and namespace?

      4. Based on thic combination (as seen in MONI message SOAP HEader->Main) are you abel to fien a receiver determination in ID? You can use the find functionality of ID

      5. Check all cache..

      Regards

      Suraj

  • Feb 25, 2010 at 01:03 PM

    Hi,

    unfortunately, I am using an integrated (advanced adapter engine) scenario, so no sxmb_moni.

    The receiver error is to seen in the message log of rwb but no message was attached to it.

    I made some more experiments:

    When I use Content conversion in the sender adapter and map it to the dummy payloadl xml, I can see now the following result in Message Mapping:

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_BudgetPayload xmlns:ns0="urn:xxx.de:budgeting">
       <PAYLOADREC>
          <PAYLOAD>XYXYXYXYXYXY</PAYLOAD>
       </PAYLOADREC>
    </ns0:MT_BudgetPayload>
    

    where XYXYXY is the binary payload.

    But when I try to map it to the field "PAYLOAD" to the field content of the XIMAIL30 schema for "Mail Package", I get the error:

    Conversion error...UTF-8-.... NO XML valid character etc...

    Your code from the beginning is doing the content conversion, but from the complete payload.

    Any hint for me?

    Thanks for all your patience

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Holger,

      >>But when I try to map it to the field "PAYLOAD" to the field content of the XIMAIL30 schema for "Mail Package", I get the error:

      Conversion error...UTF-8-.... NO XML valid character etc...

      After using FCC in sener file adapter you get a XML payload, right? and then you tried to map (using graphica mapping) it to the content field of the MAil package XSD and got an error?

      Can you do a standalone(in ESR test tab) testing of the operation mapping (or message mapping) which you have created and see if you are getting any error. Also please post the complete error message here.

      Regards

      Suraj

  • avatar image
    Former Member
    Feb 25, 2010 at 06:23 AM

    Hi Holger,

    Just a suggestion:

    1. Read the binary file using file adapter (in binary mode)

    2. use a mail package and put the read content into the Content node of it. You can use this java mapping for it

    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import  com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import com.sap.aii.mapping.api.InputHeader;
     
    public class JavaMapping extends AbstractTransformation {
         public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
    	getTrace().addInfo("JAVA Mapping Called");
    	
    	//Input payload is obtained by using arg0.getInputPayload().getInputStream()
    	String inData = convertStreamToString(arg0.getInputPayload().getInputStream());
    	
    	String outData = inData
    	
    	try
    	{
    	//8. The JAVA mapping output payload is returned using the TransformationOutput class
    	// arg1.getOutputPayload().getOutputStream()
    		arg1.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
    	}
    	catch(Exception exception1) { }
         }
         public String convertStreamToString(InputStream in){
    	StringBuffer sb = new StringBuffer();
    	try
    	{
    	InputStreamReader isr = new InputStreamReader(in);
    	Reader reader =
    	new BufferedReader(isr);
    	int ch;
    	while((ch = in.read()) > -1) {
    		sb.append((char)ch);}
    		reader.close();
    	}
    	catch(Exception exception) { }
    	return sb.toString();
        }
    }
    

    Then provide the filename dynamically into the ContentType of the mail package.

    I guess this should work.

    Regards

    Suraj

    Add comment
    10|10000 characters needed characters exceeded