cancel
Showing results for 
Search instead for 
Did you mean: 

Content Type - Mail Sender

rhviana
Active Contributor
0 Kudos

Hi experts,

So I have issue here to read the XML files from e-mail attached.

When the content type of the XML is defined as - text/xml or application/octet-stream the SAP PI do not read the MailAttachment-1 and get an error.

Check imagem below:

So I already use the MessageTransformBean to convert that, but maybe I did wrong configuration:

Somebody have the same issue ?

Kind regards,

BR.

Ricardo Viana.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi Ricardo,

  I got same situation earlier. Attachment is excel. Can you please try below message and payload swapbean.

Follow the below sequence in module tab. Use xml as extention.

Hope his will help.

Thanks,

SAI

rhviana
Active Contributor
0 Kudos

Sai,

As I mentioned before, it´s a multiple attachments.

Regards,

engswee
Active Contributor
0 Kudos

Ricardo

As mentioned by Amit, try swapping the payload first. You will need to do this to access the attachment.

Following thread has a sample of swapping by payload name.

Rgds

Eng Swee

rhviana
Active Contributor
0 Kudos

Eng,

Thanks for replay.

So as I mentined above, there is a module adapter for multiples attacments, it´s not possible use PayloadSwapBean in this case.

Any idea ?

Regards,

BR.

Ricardo Viana.

Former Member
0 Kudos

Hi Ricardo, what does the error say?

rhviana
Active Contributor
0 Kudos

Aaron,


SAP PI does not indentify the XML Attachment and get error:

<SAP:Code area="OUTBINDING">CO_TXT_OUTBINDING_ERROR</SAP:Code>

But when the XML it´s defined as application/xml, it´s works proprely.

Regards,

Former Member
0 Kudos

Hello,

>>So I already use the MessageTransformBean to convert that, but maybe I did wrong configuration:

With ur config. the content type of an attachment is getting changed??

Try using payload swap bean first and then set content type of an attachment?

Thanks

Amit Srivastava

rhviana
Active Contributor
0 Kudos

Amit,

Thanks for replay.


It´s not possibe use PayloadSwapBean first, because there is a module adapter to read multiples attachments.

I need figure out another way to change the ContenType of MailAttachment-1,2,3,4... !?

Do you have any idea ?

Regards,

BR.

Ricardo Viana.

Former Member
0 Kudos

Hello,

If that's the case, why don't u set content type in the module?

Thanks

Amit Srivastava

engswee
Active Contributor
0 Kudos

Hi Ricardo

Standard adapter modules only work on the main payload, unless you swap it with the swap bean. Since for your case using swap bean is out of the question due to multiple attachment, a possibility would be adding additional code in your custom module as suggested by Amit.

You can try it with the following logic that iterates over all the attachment and changes the content type.


   Iterator iter = msg.getAttachmentIterator();

   while(iter.hasNext()) {

    XMLPayload attachment = (XMLPayload) iter.next();

    attachment.setContentType("application/xml");

   }

Rgds

Eng Swee

rhviana
Active Contributor
0 Kudos

Eng,

I´m trying to include it, but not working, look small part of my code:

   String attachId = "";

   Attachment attach = null;

   String strAcumulaDados = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +

   "<ns0:Messages xmlns:ns0=\"http://sap.com/xi/XI/SplitAndMerge\">";

   String attType = "";

   while (itAtt.hasNext()) {

    if ( attachId.length() > 0 )

    output.getOutputAttachments().removeAttachment(attachId);

    attachId = (String) itAtt.next();

    attach = ipAtt.getAttachment(attachId);

    attType = attach.getContentType();

 

   }

    if (attType.contains("xml")) {

     String XML = "";

     XML = this.getUTF8(attach.getContent());

I´m using a java mapping with multimapping to collect the attachments and the rest of work is with InterfaceColletion.

Regards,

engswee
Active Contributor
0 Kudos

Hi Ricardo

The code that I provided above was for the custom adapter module GetMultiAnexoXml2 that was shown in your module screenshot. It's just to change the content type for attachments to application/xml as you requested for, and it's not applicable for Java mapping.

Not sure what is your design - what is being done in module and what is being done in Java mapping.

Anyway, had a look at your code and here are some of my comments:-

i) itAtt not defined anywhere

ii) attachId is initialized to blank and not updated, so the condition attachId.length > 0 will never be true.

Rgds

Eng Swee

rhviana
Active Contributor
0 Kudos

Eng,

Forget about this code above, it´s another solution, I did confusion.

So I will figure out how to fix this issue...

Regards buddy,

BR.

Ricardo Viana.