DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Transformaing SFTP poller files into SOAP with Attachment in MPGW

  • 1.  Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/14/20 10:20 AM

    Hi...

    1. I have a Multi Protocol Gateway object defined in datapower which has SFTP poller handler used to transfer files between source and destination directories between 2 hosts

    2. I have defined a Web service proxy object defined in datapower which accepts SOAP message with attachment and sends the attachment to ICAP server for Anti-Virus scanning.

    Basically, I want know, how to read the file data in MPGW and convert it into an attachment and send it to WSP as an SOAP with Attachment SWA for AV scanning(Send the file picked up by SFTP poller to WSP / AV server for scanning).

    Please let me know how can I convert the file content into an SOAP with attachment (by populating a default SOAP message) in MPGW and feed that to WSP to make the solution work.



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/16/20 10:33 AM

    Hi,

    HermannSW posted a blog about making SWAs, but they got destroyed with the old forum. Hopefully Hermann is able to republish the old posts. I think there was some kind of example in NonXMLProcessing-Advanced (https://www.ibm.com/support/pages/sites/default/files/support/swg/swgdocs.nsf/0/c8f53089493290d185257904006bff2d/%24FILE/WSTE-10132011-NonXMLDataProcessingWDPStylesheetsAdvanced-Wilbrandt.pdf). I hope it gives you an idea how to achieve your goal.

    --Hermanni



    #DataPower
    #Support
    #SupportMigration


  • 3.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/17/20 12:35 PM

    Hi... Thanks for your suggestion. I am using GatewayScript to create a SOAP message and just access the incoming file data and convert it into an attachment in gateway script. However, I am getting error in doing so,

    Below is my code,

    session.input.readAsBuffer(function (error, buffer) {

    if (error) {

    });

    });

    });

    });

    });

    });

    });

    });

    });

    });

    });

    });

    });

    });

    });

    The error which I am getting is,

    Sat Oct 17 2020 13:15:08 [0x85800007][gatewayscript][error] mpgw(AV_Test_MPGW): tid(5531503)[request] gtid(7d9173765f8ab61c0054676f): GatewayScript processing Error 'TypeError: session.output.attachment.create is not a function In file 'local:///AntiVirus/SoapAttachment.js' line:15, stack:TypeError: session.output.attachment.create is not a function at Object.<anonymous> (local:///AntiVirus/SoapAttachment.js:15:28)' Sat Oct 17 2020 13:15:08 [0x80c00009][multistep][error] mpgw(AV_Test_MPGW): tid(5531503)[request] gtid(7d9173765f8ab61c0054676f): request AV_TEST_MPGW_Policy_rule_0 #1 gatewayscript: Transforming the content of INPUT. The transformation local:///AntiVirus/SoapAttachment.js is applied. The results are stored in tmpOp. failed: Internal Error Sat Oct 17 2020 13:15:08 [0x00d30003][mpgw][error] mpgw(AV_Test_MPGW): tid(5531503)[error] gtid(7d9173765f8ab61c0054676f): Rejected by filter; SOAP fault sent



    #DataPower
    #Support
    #SupportMigration


  • 4.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/17/20 12:38 PM
    session.input.readAsBuffer(function (error, buffer) { if (error) { // handle error session.output.write (error.errorMessage); } else { var header_object = {"Content-Type": "text/plain"}; var data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:attachment.ws.it\"><soapenv:Header/><soapenv:Body><urn:Input>EICAR.txt</urn:Input></soapenv:Body></soapenv:Envelope>"; var newBuff = data; var ctx = session.name('myContext') || session.createContext('swa'); ctx.setVariable('swa',data); session.output.attachment.create('cid:newatt1', header_object, buffer, function(error) { if (error) { console.error('fail to create new attachment '+error); } }); session.output.write(data); } });

    #DataPower
    #Support
    #SupportMigration


  • 5.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/19/20 07:15 AM

    Ok. I think create is not supported... The supported operations are listed here:


    https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.7.0/com.ibm.dp.doc/context_js.html


    --Hermanni



    #DataPower
    #Support
    #SupportMigration


  • 6.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/25/20 05:57 AM

    Hi...

    In the provided link, the below example has been provided for Create operation to create the context. Please find below the same. Please let me know if the below is supported. Thanks

    var header_object = { "Content-Transfer-Encoding": "base64", "Content-Type": "text/plain" }; var data = XML.parse("<foo>bar</foo>"); session.output.attachment.create('cid:newatt1', header_object, data, function(error) { if (error) { console.error('fail to create new attachment '+error); } });

    #DataPower
    #Support
    #SupportMigration


  • 7.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 10/26/20 03:03 PM

    Yes, the create operation is listed, but in the beginning of the page it is not listed as supported ones. It is a bit unclear... Operations listed as supported seem to work but other ones don't.

    --Hermanni



    #DataPower
    #Support
    #SupportMigration


  • 8.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 11/23/20 10:11 AM

    Hi...

    I tried as per the above blog of making a SWA message and my intention is to use the file picked up by datapower SFTP poller as a attachment, but I am getting 'DataGlue' feature is not supported in your appliance error. Please advise.

    <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:dpfunc="http://www.datapower.com/extensions/functions" xmlns:func="http://exslt.org/functions" xmlns:dyn="http://exslt.org/dynamic" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:set="http://exslt.org/sets" extension-element-prefixes="dp dyn func regexp exsl set" exclude-result-prefixes="dp dpconfig dyn dpfunc func regexp exsl set" > <dp:input-mapping href="store:///pkcs7-convert-input.ffd/" type="ffd"/> <dp:output omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:variable name = "dummy"> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn="urn:attachment.ws.it\"> <soapenv:Header/><soapenv:Body> <urn:Input>EICAR.txt</urn:Input></soapenv:Body></soapenv:Envelope> </xsl:variable> <dp:set-variable name="'var://context/swa'" value="$dummy" /> <dp:set-http-request-header name="'Content-Type'" value="'application/octet-stream'" /> <dp:url-open target="attachment://swa/cid:nonXML" data-type="base64" response="ignore"> <xsl:value-of select="." /> </dp:url-open> </xsl:template> </xsl:stylesheet>

    Error

    Mon Nov 23 2020 14:07:36 [0x80a002a0][xslt][error] xmlmgr(SFTPXMLManager): tid(13910639) gtid(7d9173765fbb89e800d4426f): xslt: Request failed to compile. Fatal Error at local:///AntiVirus/swa.xsl:17: The appliance does not support the DataGlue feature. Referenced by local:///AntiVirus/swa.xsl.

    Mon Nov 23 2020 14:07:36 [0x80c00009][multistep][error] mpgw(AV_Test_MPGW): tid(13910639)[request] gtid(7d9173765fbb89e800d4426f): request AV_TEST_MPGW_Policy_rule_2 #1 route-action: Setting route with context INPUT and style sheet local:///AntiVirus/swa.xsl. failed: Fatal Error at local:///AntiVirus/swa.xsl:17: The appliance does not support the DataGlue feature.

    Mon Nov 23 2020 14:07:36 [0x00c30002][mpgw][error] mpgw(AV_Test_MPGW): tid(13910639)[error] gtid(7d9173765fbb89e800d4426f): Compilation error



    #DataPower
    #Support
    #SupportMigration


  • 9.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 11/23/20 11:43 AM

    You cannot use FFD if you don't have Integration Module. Is your input file binary or XML or something else?


    --HP



    #DataPower
    #Support
    #SupportMigration


  • 10.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 12/01/20 02:43 PM

    Hi...


    I am trying to test with a file (for example, test.txt)using sftp poller / MPGW) which is having plain text. In the swa.xsl, which I have configured in my MPGW processing policy, I intend to make a SOAP message and add this file(test.txt) as an attachment ​and proceed further. When the processing policy executes, I am getting the error which I mentioned in previously. Thanks



    #DataPower
    #Support
    #SupportMigration


  • 11.  RE: Transformaing SFTP poller files into SOAP with Attachment in MPGW

    Posted 12/07/20 08:39 AM

    Hi,

    here is an example how you can create SWA with GatewayScript. Hope it is something that you can use.


    var hm = require('header-metadata');


    session.input.readAsBuffer(function (error, buffer) {

      if (error)

      {

        // handle error

        session.output.write (error.errorMessage);

       } else {

    //Create a boundary id, make sure that it isn't present in the payload

    var boundary = "xyz123";

    //Line break

    var crlf = '\r\n';

    //Create a soap message payload

    var soap_message = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><foo>the soap message body part goes here</foo></soapenv:Body></soapenv:Envelope>';

    //Create the multipart message payload

    var multipart = '--' + boundary + crlf + 

    'Content-Type: text/xml' + crlf + crlf + 

    soap_message + crlf + '--' + boundary + crlf + 

    'Content-Type: text/plain' + crlf +

    'Content-Transfer-Encoding: base64' + crlf +

    'Content-ID: <my attachment>' + crlf + crlf + 

    buffer.toString('base64') + crlf + '--' + boundary + '--' + crlf;

    //Concatenate a new content-type header value

    var contentType = 'multipart/related; boundary=' + boundary + ' type="text/xml"';

    //Set the content type header created above

    hm.current.set('Content-Type', contentType);


    //Write payload into output

    session.output.write(multipart);

       }

    });




    #DataPower
    #Support
    #SupportMigration