DataPower

 View Only
  • 1.  PDF attachment handling in response

    Posted Tue April 30, 2024 01:01 AM

    Hi team, 

    I am looking for a case where client will be triggering a request to datapower to fetch pdf file (2/3mb) in response. 
    Can you please guide how this can be achieved from MPGW? 

    Client request will be REST or XML. 
    Response will be one pdf file. 

    For every call we are looking for one pdf in response. 

    Also please guide on how the attachment size can be restricted. 

    Thanks ! 
    -Prathamesh



    ------------------------------
    Prathamesh Dixit
    ------------------------------


  • 2.  RE: PDF attachment handling in response

    IBM Champion
    Posted Tue April 30, 2024 09:08 AM

    I suspect you already know the request as a GET (I suppose).  That is, there are a million ways to request a PDF, and that depends wholly on how you have your infrastructure configured.   If that part is a mystery, you'll need to provide more information on where the PDF resides and what protocol is needed to fetch it.

    For returning it to the requesting client, I would recommend just using a pass-thru response ( by selecting pass-through for the response rule on the gateway configuration itself ).  The response rule needs to be nothing more than a match all and results... though it will not be used.

    I'm a bit curious why you're worried about response size.  It seems to me the document sizes should be controlled by the storage mechanism, or if the documents are dynamically generated, by the generating mechanism.  Unless, hmmmm, these documents are not directly in your control.

    To control this, you might can get away with examining the content length header (easy way if the document size is represented there).  Otherwise, look into the document-size XSL extension function.  With this, though, you'll also need to consider the document size settings of the associated XML Manager so you can parse and examine the size.



    ------------------------------
    Joseph Morgan
    ------------------------------



  • 3.  RE: PDF attachment handling in response

    Posted Thu May 02, 2024 01:44 AM

    Hi Joseph, 

    Thanks for your time and revert. 

    So, the more information is, integration will be like : 

    Front app --> REST API JSON --> Datapower --> https backend application 
    Front app will be sending json message (POST I consider) , which will be converted into Pdf file from backend system and returned back. 

    Also, is there any ways that I can send the PDF from datapower to any fileshare location in response? It will be something like : 
    Request : Front app -- > Datapower --> Backend generates PDF
    Response : Generated PDF on backend --> Datapower --> Fileshare Location



    ------------------------------
    Prathamesh Dixit
    ------------------------------



  • 4.  RE: PDF attachment handling in response

    IBM Champion
    Posted Thu May 02, 2024 01:01 PM

    Last question answered first:   Yes, just use a Results action in the response or use the gatewayscript urlOpen.open(..) method.  If using a Results action, be sure to set the rule to non-XML (which you likely have to do anyway).

    So, what I would do:  Configure/Program the backend to limit the size of the response.  Otherwise, you are processing the binary in DataPower, which you can do, but I would think that is better suited to the PDF generator rather than DataPower.

    Do you still care about the size of the generated PDF if you're sending it to a file share?

    Will the client retrieve the PDF from the file share, or will DataPower still return the document to the client?



    ------------------------------
    Joseph Morgan
    ------------------------------



  • 5.  RE: PDF attachment handling in response

    Posted Thu May 02, 2024 11:22 PM

    Hi Joseph, 

    Thanks for your revert again. 

    I am looking for both possibilities. 
    1. Client retrieving the PDF from datapower  - Which I believe will be simple passthrough response rule?
    2. Datapower sending pdf directly to file share location? Can var:service/routing-url in response rule help me to send it directly to file share location? 

    ABOUT FILE SIZE - No. I do not care much about the size much at this moment. However, I would be happy to set it just to avoid any parsing errors on xml manager - without causing any load to datapower - especially heavy files if any. 

    Prathamesh




    ------------------------------
    Prathamesh Dixit
    ------------------------------



  • 6.  RE: PDF attachment handling in response

    IBM Champion
    Posted Fri May 03, 2024 11:41 AM
    1. Yes.  If you set the response rule to pass-through, but that prevents #2, since you have to process to send to another remote location.
    2. No.  Setting var:/service/routing-url in the *response* rule does nothing useful for you.  You'll need to explicitly make an outbound call to make that happen, and there are a few fundamental ways:
      1. Setup a results action in the response rule with the correct information to send document to the remote file share.  This is likely the easiest way, since it is just a configuration setting.
      2. Add a Transform action to the response rule and write the xslt to use a dp:url-open to send the document to the remote file share.
      3. Add a GatewayScript action to the response rule and write the GatewayScript using the urlOpen.open to forward the document to the remote file share.



    ------------------------------
    Joseph Morgan
    ------------------------------