• Share
  • ?
  • Profiles ▼
  • Communities ▼
  • Apps ▼

Blogs

  • My Blogs
  • Public Blogs
  • My Updates
  • Administration
  • Log in to participate

▼ Tags

 

▼ Similar Entries

sync_wait.js and wai...

Blog: HermannSW
HermannSW 2700006U54
Updated
0 people like thisLikes 0
No CommentsComments 0

How to generate UUID...

Blog: HermannSW
HermannSW 2700006U54
Updated
0 people like thisLikes 0
No CommentsComments 0

z/VSE requirement fo...

Blog: Ingolf's z/VS...
Ingolf24 120000DRN3
Updated
0 people like thisLikes 0
CommentsComments 1

Part 2 : Deploy a No...

Blog: Malarvizhi K ...
Malarvizhi_Kandasamy 060000VYUA
Updated
0 people like thisLikes 0
CommentsComments 2

Part 1 : Deploy a No...

Blog: Malarvizhi K ...
Malarvizhi_Kandasamy 060000VYUA
Updated
0 people like thisLikes 0
No CommentsComments 0

▼ Archive

  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • September 2018
  • March 2018
  • November 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • October 2016
  • May 2016
  • April 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011

▼ Blog Authors

HermannSW

View All Entries
Clicking the button causes a full page refresh. The user could go to the "Entry list" region to view the new content.) Entry list

Writing binary data to "temporary:" folder file in XSLT

HermannSW 2700006U54 | | Tags:  datapower gatwwayscript binary dump-nodes folder temporary nodejs rfe non-xml xslt javascript ‎ | 14,095 Views

There is only one way writing files to DataPower filesystem not going through XML Management set-file request:

<dp:dump-nodes> allows to store a nodeSet under a specified filename in "temporary:" folder.

nodeSet has one limitation, and that is that you cannot store arbitrary (binary) files that way.

Adding this functionality (write binary files) to dump-nodes was what RFE 71699 was about.
Customer did know that storing base64 encoded binary data is possible, but wanted to be able to write binary data.

OK, an RFE (Request For Enhancement) requests to add new functionality to a next major release. RFE 71699 was rejected because writing binary data to temporary: folder is possible with today's firmware. Yes, you need the latest 7.2.0.x firmware (for "dp:gatewayscript()" and GatewayScript "_.readsAsXML()"), but 7.2.0 is definitely earlier available than a next major release. The RFE developer update describes in short how to do with v7.2.0 firmware, this blog posting will give you the details.

OK, first we have to write (binary) data to a file in "temporary:" folder with GatewayScript. This can be done via the "fs" (filesystem) API in writing eg. a Buffer. The tricky part is how a XSLT can pass a binaryNode to GatewayScript. A binaryNode is handled in DataPower as "special" XML. And therefore you have to read the input via readAsXML(), the nodelist returned will contain just a single element for a binaryNode passed from XSLT, and that can be easily ".toBuffer()"ed. So this is the complete GatewayScript fs.write.js (click for download):

image


 

 

Now we need only to pass a binary node in XSLT in dp:gatewayscript() call, stylesheet fs.write.xsl (click for download) shows that there is no magic at all, just pass the binaryNode as "input" in dp:gatewayscript() [you have to store "fs.write.js" above into "local:" folder]

image


 


Here you can see coproc2 call that executes XSLT and passed Non-XML data (0x03 is no valid XML character):
$ coproc2 fs.write.xsl <(echo -en 'te\x3t') http://dp6-l3:2224
$ 

 

 

And here we see in DataPower CLI what is going on:

xi50(config)# dir temporary:               
   File Name                    Last Modified                    Size
   ---------                    -------------                    ----
   log/                         Jan 27, 2016 1:24:05 PM          4096
   datapowerjs/                 Jan 11, 2016 11:56:03 AM         4096
   export/                      Jan 11, 2016 11:56:03 AM         4096
   dpmon/                       Jan 28, 2016 5:16:00 AM          4096
   ftp-response/                Jan 11, 2016 11:56:03 AM         4096
   image/                       Jan 7, 2016 8:37:04 AM           4096

   221792.9 MB available to temporary:

xi50(config)# show file temporary:test.dat


% Unable to display 'temporary:test.dat' - file is not printable


xi50(config)# dir temporary:               
   File Name                    Last Modified                    Size
   ---------                    -------------                    ----
   log/                         Jan 27, 2016 1:24:05 PM          4096
   datapowerjs/                 Jan 11, 2016 11:56:03 AM         4096
   test.dat                     Jan 28, 2016 5:25:01 AM          4
   export/                      Jan 11, 2016 11:56:03 AM         4096
   dpmon/                       Jan 28, 2016 5:16:00 AM          4096
   ftp-response/                Jan 11, 2016 11:56:03 AM         4096
   image/                       Jan 7, 2016 8:37:04 AM           4096

   221792.9 MB available to temporary:

xi50(config)# 

 

 

Hermann.

 

Modified on by HermannSW 2700006U54
  • Add a Comment Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry
Notify Other People
notification

Send Email Notification

+

Quarantine this entry

deleteEntry
duplicateEntry

Mark as Duplicate

  • Previous Entry
  • Main
  • Next Entry
Feed for Blog Entries | Feed for Blog Comments | Feed for Comments for this Entry