cancel
Showing results for 
Search instead for 
Did you mean: 

How to receiver binary pdf attachment from proxy to PI

0 Kudos

Please help me with below query:

It is a sync scenario.

SOAP outbound Sync <-> PI <-> Proxy Inbound sync.

Request : Basically Webservice calls PI with Id number. PI calls  proxy to input the ID number.

Response : Proxy generates pdf(Binary) against the Id number & PI to receive document as response. This document is sent to webservice as binary attachment.

I have verified Michael's blog on proxies with attachment but my abaper says its not possible in our scenario since ABAP generates the pdf & there is no place that ABAP can store that pdf. (Client is not ready SFTP/FTP maintenance so this is not our option).


Please suggest.

Accepted Solutions (0)

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Harry,

If that is the case, just encode the pdf as a base64 and pass it into a field(string) in the proxy. Once PI receives the response message, the base64 content can be retrieved and an attachment can be created via UDF in message mapping.

Regards,

Mark

0 Kudos

Thanks for your valuable inputs Mark.

Once PI sends the document ID to ECC. ABAPer said after generating the file he will send it in a table as base64.. I requested to send the pdf in 1 field & so that I could send the file as string without further conversion. But we are facing challenge in  sending the base64 to PI. I would like to understand if in ECC Proxy can send the entire message in 1 string if so how. Is it through populating the values in table as ABAPer insisted.

Sorry I have an other query aswell. In sync mode for other interface, SOAP sends order number & ECC generates the order & sends back the order details if the request is successfully sent to proxy & corresponding document is generated but while sending the response if the message fails to go to SOAP &it times out. WIll the response be reprocessed. I understand sync messages cant be restarted but can the failed message retry per the interval.Since SAP cant auto-cancel the generated order & sender wont be able to understand if the corresponding order has been generated or. Could you please guide me on how to handle this.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Harry,

For encoding to base64, you can use SCMS_BASE64_ENCODE or CL_HTTP_UTILITY=>ENCODE_X_BASE64.


Maybe you can create a program to auto-cancel the generated order after a specified time e.g 15minutes.

Regards,

Mark

nabendu_sen
Active Contributor
0 Kudos

Hi Harry,

Check the threads:

Sync ABAP Server Proxy - Attachment in Response... | SCN

Regards,

Nabendu.

0 Kudos

Thanks for your quick response Nabendu the michael's blog is not working for us & as for STefan;s response we are on 7.3 SAP NW so I guess its not the issue.

stefan_grube
Active Contributor
0 Kudos

What is the release of your bac edn (ABAP) System? It should work starting 7.0

The code in that thread should work, however I have not tested it by my own.

https://scn.sap.com/thread/1890020

0 Kudos

Hi Stefan,

Thanks for responding.

We have handled this in ECC.

Proxy will generate pdf & convert it into binary text & returns to PI in single string. Once the binary text is returned to webservice, the receiving application has a capability of converting text to pdf.

But I'm still stuck.

My client sent me WSDL, which was composite & was referenced to xsd1 which was referenced to xsd2 which had the actual request & response fields. (wsdl -> xsd1 & xsd1 -> xsd2).

So I directly used xsd2 in PI service interface as request & response.

I triggered the test from XML spy to Wsdl url I generated, then a proxy was called, proxy generated pdf file & converted it into binary text & sent to PI in 1 field as a string which was successfully delivered & I received below response. But my question is where did the file end up, if its on PI generated webservice, I'm wondering how it can integrate with the clients tool of binary to pdf conversion. This interface is already in prod & we are replacing SAP so client is expecting a pdf file.I believe I have to provide this URL & ask the client to point their conversion agent to pick the binary text from PI generated URL or was my approach of generating WSDL without the original references mess up. I'm failing to understand the communication link here. Sorry I haven't worked on sync scenario earlier. Could you please guide me.

Response:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">

  <SOAP:Header/>

  <SOAP:Body xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <ns1:InvoiceInfo xmlns:ns1="http://Clients namespace">

  <DocumentContainer>

  <File>255044462D312E330A25AAABACAD0A342030206F626A0A3C3C202F54797065202F496E666F0A2F50726F647563657220286E756C6C29203E3E0A656E646F626A0A352030206F626A0A3C3C202F4C656E6774682033323030202F46696C746572202F466C6174654465636F6465200A203E3E0A73747265616D0A789CC55BC98</File>

  </DocumentContainer>

  </ns1:InvoiceInfo>

  </SOAP:Body>

</SOAP:Envelope>

Also when I access the endpoint, it gives below message, I'm wondering if client can access PI's webservice.

Message Servlet is in Status OK

Status information:

Servlet com.sap.aii.adapter.soap.web.MessageServlet (Version $Id: //tc/xpi.adapters/NW731EXT_15_REL/src/_soap_application_web_module/webm/api/com/sap/aii/adapter/soap/web/MessageServlet.java#1 $) bound to /MessageServlet

Classname ModuleProcessor: null

Lookupname for localModuleProcessorLookupName: localejbs/ModuleProcessorBean

Lookupname for remoteModuleProcessorLookupName: null

ModuleProcessorClass not instantiated

ModuleProcessorLocal is Instance of com.sun.proxy.$Proxy20725

ModuleProcessorRemote not instantiated

0 Kudos

Stuck again.

Requirement changed. ABAP decided to  upload the pdf file to FTP. For some reason ABAP says its complicated & cannot generate .pdf file in runtime.

So I'm planning to employ sync-async bridge.

Like SOAP outbound sync<-> Proxy Inbound sync with (requestresponsebean)

Flow Request -> (Webservice requests document ID, Proxy generates pdf & saves to FTP).

In soap XI channel I will use requestBean to input document ID & responseBean to get the pdf file convert the pdf to binary response mapping(I'm not sure yet how to do the conversion from pdf to binary but visualized this approach) & pass it to webservice as a string.

Please help if this is practically possible if at all it is, then does it affect performance in a real time scenario due to timeouts.

Experts please guide me.

Ryan-Crosby
Active Contributor
0 Kudos

Hi Harry,

It should not be difficult to generate a PDF in the back-end system and provide the data.  Here are two FMs that can be used to convert SAPScript or Smartforms output to PDF or the other option is an Adobe Form which can also be trapped to get the data in XSTRING format (essentially hex string):

SAPScript - CONVERT_ABAPSPOOLJOB_2_PDF

Smartforms - CONVERT_OTFSPOOLJOB_2_PDF

The hex string can then be converted into a stream in a java mapping very easily.  We have a scenario where we do this to import employee photos into our HR system in .jpg format.


Regards,

Ryan Crosby

0 Kudos

Appreciate your response Ryan!!

Unfortunately ABAPer says its not possible for them to convert the smartform into binary or xstring in runtime. It can be done if the file is generated & is on application server or presentation server but not in runtime.

Basically the flow is webservice calls PI with Document ID, PI sends the document ID to SAP. SAP generates smartform converts to pdf file & puts it in ftp server. Pi picks the file converts it into base64/binary pass it to webservice in a single string. Receiving webservice has a capability of converting the binary file to PDF.

This is already in prod, webservice would not make any change from their end. SAP is replaced with current middle-ware, so all the change is done in SAP & PI.

I have 2 approaches as below:

1. To break this into 2 async interfaces. Once I receive the doc ID request from webservice, PI will call proxy. In 2nd async I will use file-> soap. And set the file to poll every 10 sec.so as soon as the doc is saved on the ftp folder PI will invoke the webservice. But I'm not sure if client will agree for this trigger/async call.since he wants everything in 1 call as request & response.

2.Sync-Async bridge.

Like SOAP outbound sync<-> Proxy Inbound sync with (requestresponsebean)

Flow Request -> (Webservice requests document ID, Proxy generates pdf & saves to FTP).

In soap XI channel I will use requestBean to input document ID & responseBean to get the pdf file convert the pdf to binary response mapping(I'm not sure yet how to do the conversion from pdf to binary but visualized this approach) & pass it to webservice as a string.

What do you say

Ryan-Crosby
Active Contributor
0 Kudos

Hi Harry,

I believe the ABAP'er is mistaken as you only need a Smartform that has been sent to the spool to achieve this.  See the function signature below where I have highlighted the name and the exporting reference to extract the XSTRING formatted data of the PDF:

If this is something that takes a long time to generate however and you are worried about runtime for a synchronous call then yes, it would probably be better to break it into two separate asynchronous interfaces.

Regards,

Ryan Crosby

0 Kudos

Hey Ryan,

Abaper has somehow tried converting the smartform to pdf & returning the binary of the pdf.

But somehow I can see the data in SAP sproxy test but not while calling the scenario in wsnavigator.

Any idea why would it do that.

> Proxy response in SAP:

<?xml version="1.0"?>

-<n0:proxy_response xmlns:prx="urn:sap.com:proxy:ECD:/1SAI/TASCD80D4E405936B335BD4:740" xmlns:n0="urn:Soap_2_Proxy_Sync">

-<InvoiceInfo>

<ID>test</ID>

<File>D312E330D(removed the rest)</File>

</InvoiceInfo>

</n0:proxy_response>

> WSNavigator Test:

<?xml version="1.0" encoding="utf-8"?>

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">

  <SOAP:Header/>

  <SOAP:Body xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <ns1:InvoiceInfo xmlns:ns1="http:test.portal.com">

      <DocumentContainer>

        <File/>

      </DocumentContainer>

    </ns1:InvoiceInfo>

  </SOAP:Body>

</SOAP:Envelope>

Basically I have mapped the proxy field -file (base64 as data type) to soap field - file.

But it did not return the binary text from proxy to soap.

I'm wondering if its any parsing issue, what do you say.

Any pointers will be helpful in this regards, Thanks.

Ryan-Crosby
Active Contributor
0 Kudos

Hi Harry,

What is your code to convert from the hexadecimal string to base 64?  Also, what kind of mapping are you using to generate the SOAP response message?  Graphical that occurs after your java mapping?

Regards,

Ryan Crosby

0 Kudos

The PDF to binary conversion is done in ABAPproxy coding by Abape & the string is returned to field fiel in proxy itself.

I'm just using 1-1 graphical mapping from file to file field, no java mapping is used. But I was wondering if I need to use any udf to pick the binary text

We are using 'CONVERT_OTF_2_PDF' & CALL METHOD cl_http_utility=>encode_x_base64

Ryan-Crosby
Active Contributor
0 Kudos

Hi Harry,

I think something is amiss with the base 64 encoding that is supposed to be happening in the ABAP proxy because that looks like direct XSTRING (hexadecimal) content and not base 64.  I don't think that would affect your ability to map it however in a graphical mapping - I would copy/paste the payload from the sample you have and run it through your graphical mapping to see what output it generates.  If you notice that the <File> node is empty there then something is going on with your graphical mapping setup.

Regards,

Ryan Crosby