Topic
  • 7 replies
  • Latest Post - ‏2015-05-26T08:17:15Z 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.
Updated on 2013-01-07T15:36:18Z at 2013-01-07T15:36:18Z by swlinn
  • kenhygh
    kenhygh
    1531 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
    4657 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/>
    Updated on 2014-03-25T02:43:51Z at 2014-03-25T02:43:51Z by iron-man
  • 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....
    Updated on 2014-03-25T02:43:10Z at 2014-03-25T02:43:10Z by iron-man
  • Daviiid
    Daviiid
    284 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>
    
    Updated on 2014-03-25T02:43:06Z at 2014-03-25T02:43:06Z by iron-man
  • swlinn
    swlinn
    1348 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
    7 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
    4657 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/> |