on 09-09-2016 1:52 PM
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:
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 :
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Indu,
You can check it, taking the base stream manually and checking it online for example here: https://www.base64decode.org/
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is there a possibility that base64 decoder is not decoding properly?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
How to set the content disposition of attachment ?
Regards,
Indu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Indu,
can you try with MessageTransformationBean in SOAP sender channel after the default module(s)
Inserting MessageTransformBean in Module Processor - SAP NetWeaver Process Integration - SAP Library
Check section "Set MIME Content Fields"
Transform.ContentDisposition
Under Parameter Value enter attachment or inline.
Example: attachment;filename="abcd.xlsx"
Br,
Praveen
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Indu,
As per SAP help,
contentType - the type of the attachment. Have a look at http://de.selfhtml.org/diverses/mimetypen.htm for an overview of possible types.
for *.docx mime type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
can you try with:
contentType = "name=\"file1.docx\""; application/vnd.openxmlformats-officedocument.wordprocessingml.document;
for *.xlsx mime type:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
can you try with:
contentType = "name=\"file2.xlsx\""; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;
Br,
Praveen
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Manoj,
Thank you for your inputs.
I'm using this UDF:
GlobalContainer globalContainer = container.getGlobalContainer(); OutputAttachments outputAttachments = globalContainer.getOutputAttachments(); AbstractTrace trace; trace = container.getTrace(); byte[] pdfBytes; String contentType =Type[0]; String contentType ="application/msexcel"; String pdf = ""; //Loop at the Data for (int i=0; i
Thanks,
Indu.
Hello,
Can anybody provide some insights on this?
Thanks,
Indu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Navdeep,
Thanks for your feedback.
When I use the provided content type, the name of attachment in soapUI remains: Attachment.bin for both cases mentioned by you.
I'm not sure with synchronous SOAP adapter but I'm now trying dynamic configuration to change the name of attachment from attachment.bin to attachment.xlsx
Thanks,
Indu.
Hi Indu,
1. when you rename the attachment.bin with correct extension manually, does the file gets opened correctly?
2. If answer to point 1 is no, is it possible to update your code and save the decodedBytes to some file location, just to confirm if the binary you are getting in response is ok.
you can do this with following code
FileOutputStream fos = new FileOutputStream(filepath/filename);
fos.write(decodedBytes);
fos.close();
3. In SOAPUI, if you click on raw tab in the response, what content type do you see
Hi Navdeep,
when I try to open the file it shows me invalid characters/junk as it open by default in notepad.
When I save the .bin file as .xlsx and try opening it then it opens the excel file but there is a pop up prior to this : it's corrupt and do u trust the sender, on clicking yes it opens the file properly.
Thanks.
Hi Indu,
I have created a dummy interface with similar code that works with SOAPUI and shows the attachment name
I did some changes to simulate the the issue you are having, and i can see the attachment name shows as .bin only when i either don't specify the file extension or give null in the filename in the create() method
Hi Navdeep,
First of all thanks a ton for trying the scenario and taking out time for the issue. I truly acknowledge and appreciate
Secondly, could you please put the code you have used and I could not follow " file extension null in create()"; As I'm giving the file name.
Thanks,
Indu Khurana.
Hi Indu,
I am reading the file from local filesystem and leave blank in the first argument in the create method. this will have .bin as the file name in SOAPUI response
InputStream fis = new FileInputStream(file);
byte[] data = getBytesFromInputStream(fis);
Attachment attach = oa.create("", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", data);
oa.setAttachment(attach);
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
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.