Skip to Content
Technical Articles

MIME Multipart Encoder for handling more than one attachments

In this blog post you will learn use of MIME Multipart Encoder for attachment handling

I came across requirement where two attachment needs to be processed and send it to Ariba network. I decided to use MIME Multipart encoder but there was little information available on internet how to use it for attachment handling.

I am writing this blog post to understand behavior of Multipart encoder for attachment handling.

Scenario

  • Read .cxml and .pdf file from file server
  • Create providerDatarequest and add pdf and cxml file as attachment and processed to Ariba network

 

Below pdf document help to understand processing of Incomplete or image-only invoices to Ariba network.

https://www.ariba.com/ja-jp/-/media/aribacom/assets/pdf-assets/archive/ariba-invoice-conversion-service.pdf

Page no 65 to 68 help  to understand expected request format-ProviderDataRequest with image and invoice cXML attachments

I created two Iflow .

  • Iflow 1- cxml file processing—it processes cxml file and save it using CPI data store
  • Iflow2 – Main iflow- this iflow read pdf file and check for relevant cxml file data in data store. It creates ProviderDataRequest cxml and attach bot pdf and cxml file

File name is same for both cxml and pdf.

Find below screenshot for Iflow1.

Main iflow to read pdf and process both pdf and cxml as attachment

Step 1-Content Modifier–Parameter Externalization

To send data to Ariba network we need to populate below fields in ProviderDatarequest .

Except ‘ FileName2’  all parameters are externalized

Step 2-Groovy Script–Create Variables

In this step  variable are created to pass to main body-providerDataRequest and set as properties.

Step 3-Groovy script– PDF_Attach

This groovy script read pdf file and add it as attachment.This groovy script set header properties for pdf attachment.

Step 4-Data store Operation-Select

This step help to read data from Datastore (Cxml file data)

 

Router step check if there is any data available or not.If yes then continue with next step no 5. If there is no data available then raise exception and end process.

Step 5-Filter

Filter remove extra tag from data

Step 6- Content Modifier to add tag

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE cXML SYSTEM “http://xml.cxml.org/schemas/cXML/1.2.034/InvoiceDetail.dtd”>
${in.body}

Step 7 – Groovy script-InvoiceDetailRequest CXML as Attachment

This groovy script add cxml  data as attachment and set header for cxml file.

Step 8 – Groovy script- Create ProviderDataRequest XML

This  groovy script create providerDataRequest and add url for both cxml and  pdf attachment.It also set header for ProviderDataRequest.

Step 9 – MIME Multipart Encoder 1

This step add Provider data request as main body and both cxml and pdf file as attachment

Step 10– Groovy Script- Modify Content-Type

This groovy script modify content type as per expected request structure

Step 11– Content Modifier- Add Content-Type to Message

This step add Content type to main body

Content-Type: ${property.lv_cont_typ}
${in.body}

Step 12– Request-Reply

This step make call to Ariba network using HTTP adapter and post request.

Generic address https://service-2.ariba.com/service/transaction/cxml.asp

 

Step 13– Groovy script- Log Response

This step log Ariba response as attachment

 

Step 14– Data store-Delete

This step delete data store.

Step 15– End

Expected format of data before calling Ariba(Request-reply step) is as below.I removed pdf and cxml data and put dummy value.Check header field for main body and attachments.

MIME multipart encoder help to add attachment in expected format.

This request is successfully processed in AribaNetwork and attachments are posted.

Conclusion-If you activate trace and check payload before and after MIME multipart encoder,you will notice that attachments are added with predefined header and ——=_Part_XX_111777.111888(Boundary line)

Hope this blog post helps.

Thanks

Harshalata

 

4 Comments
You must be Logged on to comment or reply to a post.
  • Hi Harshalata,

    Thanks for your blog  

    I have one requirement, 

    Here,

    Sender Ariba cxml payload the attachment (“cid:1735239107.1592222922946@cxml.org”)
    document is coming in above format need to extract this content and send to base64 with third party… could you please suggest me with your inputs, that how we can extract the content.

    It’s very helpful.

    Thank you.

  • Hi Harshalata,

     

    Thanks a lot for your response.

    I have tried with the code but couldn’t able to extract the content in cxml attachment URL which is coming from Ariba system.

    I will send more details in email.

    Thanks.

  • Hi Harshalatha,

    The requirement is:

    Ariba system sending invoice attachment in the cxml payload..that we need to transfer to non sap system.

    Here 

    In Ariba attachment is coming in the payload like below

    <Attachment>

    <URL>cid:1735239107.1592222922946@cxml.org</URL>

    </Attachment>

     

    This we need to extract the content and send to non sap system.

    Here I am facing difficulty to extract the content in the above attachment.

    Or

    The cxml payload attachment it’s correct or incorrect?

    Could please help me to sort this issue.

     

    Thank you.