Topic
  • 9 replies
  • Latest Post - ‏2016-11-21T15:13:28Z by HermannSW
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic Access a file from datapower directory and send it to an external server?

‏2013-01-02T12:49:14Z |
is there any way to dynamically access a file stored a local directory in DataPower File Management and transport it via a protocol like ftp to external server??

Kindly advice a solution....tnx in adv.
  • kenhygh
    kenhygh
    2164 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2013-01-02T13:42:02Z  
    well, I'd try something like the following (not tested)

    <xsl:variable name="FileContent">
    <dp:url-open target="'local://some-file'" response="binaryNode"/>
    </xsl:variable>

    <dp:url-open target="'ftp://my-server'" response="whateverResponseYouExpect">
    <xsl:copy-of select="$FileContent"/>
    </dp:url-open>
  • HermannSW
    HermannSW
    6394 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2013-01-02T14:45:12Z  
    • kenhygh
    • ‏2013-01-02T13:42:02Z
    well, I'd try something like the following (not tested)

    <xsl:variable name="FileContent">
    <dp:url-open target="'local://some-file'" response="binaryNode"/>
    </xsl:variable>

    <dp:url-open target="'ftp://my-server'" response="whateverResponseYouExpect">
    <xsl:copy-of select="$FileContent"/>
    </dp:url-open>
    > well, I'd try something like the following (not tested)
    >
    that is unlikely to work, because processing binaryNode data can only be done by
    • either "dp:binary-encode()"
    • or "dp:output-mapping"

    This should work (also untested, see slides 18 and 19 of this webcast, hear into audio recording for details):
    <xsl:variable name="FileContent">
      <dp:url-open target="'local://some-file'" response="binaryNode"/>
    </xsl:variable>
     
    <dp:url-open target="'ftp://my-server'" response="whateverResponseYouExpect" data-type="base64">
      <xsl:copy-of select="dp:binary-encode($FileContent/result/binary/node())"/>
    </dp:url-open>
    


    Hermann <myXsltBlog/> <myXsltTweets/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2013-01-07T12:56:02Z  
    • HermannSW
    • ‏2013-01-02T14:45:12Z
    > well, I'd try something like the following (not tested)
    >
    that is unlikely to work, because processing binaryNode data can only be done by
    • either "dp:binary-encode()"
    • or "dp:output-mapping"

    This should work (also untested, see slides 18 and 19 of this webcast, hear into audio recording for details):
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><xsl:variable name="FileContent"> <dp:url-open target="'local://some-file'" response="binaryNode"/> </xsl:variable> <dp:url-open target="'ftp://my-server'" response="whateverResponseYouExpect" data-type="base64"> <xsl:copy-of select="dp:binary-encode($FileContent/result/binary/node())"/> </dp:url-open> </pre>

    Hermann <myXsltBlog/> <myXsltTweets/>
    Tnx for the response!!!!!!

    I am able to move a file from local box to externall server as follows...

    <xsl:variable name="sftp-put-url" 
    select="'sftp://username:password@**.**.**:**/~/FileSource/export.xml'" /> 
    <dp:url-open target="{$sftp-put-url}" data-type="filename" response="ignore">local:///Order.xml</dp:url-open>
    


    but now i am trying to move entire directory to server...could any one help on same!!!!

    i tried with following but no luck...... was saying unsupported urlopen URL...........
    <xsl:variable name="FileContent">
      <dp:url-open target="'local://some-file'" response="binaryNode"/>
    </xsl:variable>
    


    tnx in adv....
  • Daviiid
    Daviiid
    349 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2013-01-07T14:58:07Z  
    Tnx for the response!!!!!!

    I am able to move a file from local box to externall server as follows...

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><xsl:variable name="sftp-put-url" select="'sftp://username:password@**.**.**:**/~/FileSource/export.xml'" /> <dp:url-open target="{$sftp-put-url}" data-type="filename" response="ignore">local:///Order.xml</dp:url-open> </pre>

    but now i am trying to move entire directory to server...could any one help on same!!!!

    i tried with following but no luck...... was saying unsupported urlopen URL...........
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><xsl:variable name="FileContent"> <dp:url-open target="'local://some-file'" response="binaryNode"/> </xsl:variable> </pre>

    tnx in adv....
    Hello

    Maybe you can have to use a SOMA call

    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
            <env:Body>
                    <dp:request domain="{$YourDomain}" xmlns:dp="http://www.datapower.com/schemas/management">
                            <dp:get-filestore location="local:"/>
                    </dp:request>
            </env:Body>
    </env:Envelope>
    
  • swlinn
    swlinn
    1396 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2013-01-07T15:36:18Z  
    • Daviiid
    • ‏2013-01-07T14:58:07Z
    Hello

    Maybe you can have to use a SOMA call

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <dp:request domain="{$YourDomain}" xmlns:dp="http://www.datapower.com/schemas/management"> <dp:get-filestore location="local:"/> </dp:request> </env:Body> </env:Envelope> </pre>
    The SOMA call is the only way to get the directory listing, and you'd need to iterate thru it to build the right target on the url-open to get one file at a time, but having said that, what exactly are you trying to do from a processing rule transformation xsl?

    Regards,
    Steve
  • DivyaManaktala
    DivyaManaktala
    10 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2015-05-26T07:16:51Z  
    • swlinn
    • ‏2013-01-07T15:36:18Z
    The SOMA call is the only way to get the directory listing, and you'd need to iterate thru it to build the right target on the url-open to get one file at a time, but having said that, what exactly are you trying to do from a processing rule transformation xsl?

    Regards,
    Steve

    Hi ,

    Is it possible to access or list the directory structure using CLI commands within the XSLT?

    If possible how we can write the CLI command in XSLT.

    Thanks in advance.

    Regards,

    Divya

     

  • HermannSW
    HermannSW
    6394 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2015-05-26T08:17:15Z  

    Hi ,

    Is it possible to access or list the directory structure using CLI commands within the XSLT?

    If possible how we can write the CLI command in XSLT.

    Thanks in advance.

    Regards,

    Divya

     

    Hi,

    you cannot execute CLI commands directly in XSLT, but slide 14 of this webcast shows how you can:
    http://www-01.ibm.com/support/docview.wss?uid=swg27019118

    Better is to access the XML Management interface instead because that provides return codes for each processed item. You can do that from XSLT as well, see:
    https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/accessing_xml_management_interface_from_within_a_stylesheet38
    https://www.ibm.com/developerworks/community/blogs/HermannSW/tags/management

    You will get directory listing with  <dp:get-filestore/>  command.


    Hermann  <myBlog/>  <myTweets/>  <myChannel/>  | <GraphvizFiddle/> <Viz.js_form10/> | <xqib/> | <myCE/> <myFrameless/> | 

  • skdp
    skdp
    6 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2016-11-21T14:00:36Z  

    Hello All,

     

    I have a usecase as follows. My business tries to write a file Test.dat and when it is completed, it will write a file test.flg to indicate that it is ready for processing. How can I accomplish this using DataPower? I n other words, I have to poll for Test.flg and process Test.dat when it is available? Any help is appreciated. 

     

    Thanks in advance.

  • HermannSW
    HermannSW
    6394 Posts

    Re: Access a file from datapower directory and send it to an external server?

    ‏2016-11-21T15:13:28Z  
    • skdp
    • ‏2016-11-21T14:00:36Z

    Hello All,

     

    I have a usecase as follows. My business tries to write a file Test.dat and when it is completed, it will write a file test.flg to indicate that it is ready for processing. How can I accomplish this using DataPower? I n other words, I have to poll for Test.flg and process Test.dat when it is available? Any help is appreciated. 

     

    Thanks in advance.

    Please don't hijack old unrelated threads and create a new thread with your different issue.

    Hermann.