Skip to Content
avatar image
Former Member

Converting Binary payload(in a field) to .docx and .xlsx and send it as an attachment with SOAP adapter.

Hello PI team,

I need guidance in a synchronous scenario ; SOAP to Proxy.

A call is placed from sender SOAP channel to fetch a set of documents from ECC system. ECC system in turn calls 'opentext' server to fetch the required document.

The fetched document in Binary format is sent as a value of a field named 'List' in response payload to PI. In PI this binary data is decoded with base64 decoder and content type used is either for docx or xslx or PDF depending on the file fetched.

This converted file is send as an attachment in the response message of SOAP call.

PDF conversion and attachment is working fine.

Issue lies while converting the binary to docx and xlsx.

For docx , if content type:

  1. application/vnd.openxmlformats-officedocument.

then the attachment created is Attachment.bin not Attachment.doc

If content type = application/msword

then attachment created is Attachment.doc, it open properly but after two pop ups:

1.

2.

For xlsx, for any of the content type :

  1. application/msexcel ,
  2. application/ms-excel ,
  3. application/vnd.ms-excel,
  4. application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

the attachment in the response is getting created as Attachment.bin not attachment.xls/attachment.xlsx. .

Required is attachment.docx and attachment.xlsx in the response payload

Please suggest!

Thank You.

Indu Khurana.

second popup.jpg (27.3 kB)
first pop up.jpg (15.2 kB)
first pop up.jpg (15.2 kB)
second popup.jpg (27.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Sep 13, 2016 at 06:12 AM

    Hello,

    Can anybody provide some insights on this?

    Thanks,

    Indu.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2016 at 06:26 AM

    Indu,

    While you are converting the base64data back to the doc/xsl/pdf and setting the file as an attachment you can set content type.

    Attachment attOut = outAttach.create(filename1.replaceAl, "content-type", byte);
    

    Br,

    Manoj

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Manoj K

      Manoj, I'm working on single stack.

      I'm using soapUI as testing tool and I can see the content type in soapUI, It is whatever I have set in UDF: application/msexcel.

      Tx,

      Indu.

  • avatar image
    Former Member
    Sep 15, 2016 at 06:23 AM

    Hello everyone,

    Can anybody provide any inputs on the issue.

    The issue still persists:

    Wword attachment: pop ups with attahcments while opening

    Excel attachment: attachment.bin is getting created not attachment.xls/xslx

    Thanks,

    Indu.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Praveen Gujjeti

      Hi Praveen,

      In addition to my earlier comment, whenever I change the name changes in content type but it does not change in Name section in SOAPUI as in screenshot.

      I tried with setFileName() but it does not recognizes and fails while compiling.

      Regards,

      Indu

  • avatar image
    Former Member
    Sep 15, 2016 at 09:47 AM

    Hello,

    How to set the content disposition of attachment ?

    Regards,

    Indu.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2016 at 05:26 AM

    Hi,

    Is there a possibility that base64 decoder is not decoding properly?

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 16, 2016 at 05:58 AM

    Hi Indu,

    You can check it, taking the base stream manually and checking it online for example here: https://www.base64decode.org/

    Regards

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Inaki,

      Thank you for your inputs.

      I have compared the base64 decoded data converted at this link and in soapUI response, they look a bit different.

      But does that mean it is invalid?

      Thanks,

      Indu.

  • Sep 16, 2016 at 07:06 AM

    I saw your message in Handle SOAP with Attachment in SAP PI 7.31

    My scenario is in ABAP.

    I use get_protocol from my sproxy class.

    lo_att_protocol ?= lo_retrievedoc->get_protocol( if_wsprotocol=>attachments ).

    Next step :

    CALL METHOD lo_att_protocol->get_attachments

    RECEIVING

    attachments = li_attach.

    DESCRIBE TABLE li_attach LINES lv_count.


    for retrieving the attachment list.


    You can find information from the attachment with :

    LOOP AT li_attach INTO DATA(ls_attach).

    ls_attach->get_content_type( ).


    CALL METHOD ls_attach->get_binary_data

    RECEIVING

    p_data = gs_document-att_content.

    ENDLOOP.

    With get_binary_data i have the content of the attachment in binary.

    I save this content in XString variable.

    After I create the file with :

    OPEN DATASET lv_file FOR OUTPUT IN BINARY MODE.

    TRANSFER lv_xstring TO lv_file.

    CLOSE DATASET lv_file.

    For the extension i control the mime-type with table "sdokfext"

    xlsx = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

    Good luck,

    Youri

    Add comment
    10|10000 characters needed characters exceeded