Topic
  • 7 replies
  • Latest Post - ‏2012-06-25T22:31:50Z by ansmyke
ansmyke
ansmyke
98 Posts

Pinned topic uploading the directory on XI50

‏2012-06-15T21:21:24Z |
Hi, I need to upload a directory containing various sub directories having WSDLs and XSDs on the XI 50 appliances to validate incoming messages in an MPGW. Isn't there any way to achieve this? Uploading each file manually and maintaining the folder structure and naming convention will be a nightmare otherwise.Thanks,

Mike
Updated on 2012-06-25T22:31:50Z at 2012-06-25T22:31:50Z by ansmyke
  • swlinn
    swlinn
    1396 Posts

    Re: uploading the directory on XI50

    ‏2012-06-15T21:28:15Z  
    WAMC would be an option. If doing this on your own, you could write a script that creates a SOMA request for the XML Management Interface that will first do a dp:do-action to create all of your directories and subdirectories from your source and then will do a number of dp:set-files, having read the files and base64 encoded the content of the dp:set-file. I believe there have been threads in the forum on this subject in the past.

    Regards,
    Steve
  • irazabal
    irazabal
    218 Posts

    Re: uploading the directory on XI50

    ‏2012-06-16T00:00:53Z  
    so here is a example of how to do it, with a combination of perl, and SOMA.
    First you need a shell script to orchestrate the whole thing:
    #!/bin/bash
    1. This script automates a file retrieve session with a DP device.
    2. In this session, it uses DP SOMA commands to send a file to
    3. DP from a local directory on the client.
    #
    ARGS=6
    if ; then
    echo "Usage: dosetfile.sh USER PASS DP_HOSTNAME DP_DOMAIN SERVICE_NAME LOCAL_FILE"
    exit 1
    fi

    dp_user=$1
    dp_pass=$2
    dp_hostname=$3
    dp_domain=$4
    service_name=$5
    local_file=$6
    echo '<?xml version="1.0" encoding="UTF-8"?>' > outfile.xml

    echo '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' >> outfile.xml
    echo ' <soapenv:Body>' >> outfile.xml
    echo ' <dp:request domain="'$dp_domain'" xmlns:dp="http://www.datapower.com/schemas/management">' >> outfile.xml
    echo ' <dp:set-file name="local:///'$service_name'">' >> outfile.xml
    ./encodeFle.pl $local_file >> outfile.xml
    echo '</dp:set-file>' >> outfile.xml
    echo ' </dp:request>' >> outfile.xml
    echo ' </soapenv:Body>' >> outfile.xml
    echo '</soapenv:Envelope>' >> outfile.xml
    curl -v -k -u $dp_user:$dp_pass -d@outfile.xml $dp_hostname/service/mgmt/current

    this one take a file and sends it to a directory in DP, it calls encodeFile.pl:

    #! /usr/bin/perl
    use MIME::Base64;
    use XML::XPath;
    use Data::Dumper;
    my $file = $ARGV[0];
    my $doc = XML::XPath->new(filename => $file);
    foreach my $files ($doc->find('/')->get_nodelist){
    #print (XML::XPath::XMLParser::as_string($files));
    my $encoded = encode_base64(XML::XPath::XMLParser::as_string($files));
    print ($encoded);
    }

    if you also want to create the directory from scratch...use this:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <dp:request domain="default" xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:do-action>
    <CreateDir>
    <Dir>local:///myTestDirectory</Dir>
    </CreateDir>
    </dp:do-action>
    </dp:request>
    </env:Body>
    </env:Envelope>

    not the most straight forward way, but it works...
    Alex
  • HermannSW
    HermannSW
    6379 Posts

    Re: uploading the directory on XI50

    ‏2012-06-18T12:18:58Z  
    Hi,

    > Hi, I need to upload a directory containing various sub directories having WSDLs and XSDs on the XI 50 appliances to validate incoming messages in an MPGW.
    > Isn't there any way to achieve this? Uploading each file manually and maintaining the folder structure and naming convention will be a nightmare otherwise.
    >
    I assume that you want to do this on a development box, since there are better ways to deploy production configuration.

    Besides the options Steve and Alex mentioned, you can rely on a DataPower based solution.
    zip-copy.xsl copies everything you have put into a .zip archive and stores it under local.
    Directory structure is preserved, you can specify domain, whether you want directories deleted before, ...
    See "zip-copy.xsl" posting for details:
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/zip_copy_xsl

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • HermannSW
    HermannSW
    6379 Posts

    Re: uploading the directory on XI50

    ‏2012-06-18T12:21:02Z  
    • HermannSW
    • ‏2012-06-18T12:18:58Z
    Hi,

    > Hi, I need to upload a directory containing various sub directories having WSDLs and XSDs on the XI 50 appliances to validate incoming messages in an MPGW.
    > Isn't there any way to achieve this? Uploading each file manually and maintaining the folder structure and naming convention will be a nightmare otherwise.
    >
    I assume that you want to do this on a development box, since there are better ways to deploy production configuration.

    Besides the options Steve and Alex mentioned, you can rely on a DataPower based solution.
    zip-copy.xsl copies everything you have put into a .zip archive and stores it under local.
    Directory structure is preserved, you can specify domain, whether you want directories deleted before, ...
    See "zip-copy.xsl" posting for details:
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/zip_copy_xsl

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    This is the test archive I used, contains empty directories, a zero size file, a top level file, ...
    $ unzip -l a.zip
    Archive:  a.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
            0  06-16-2012 16:51   a/ 
            0  06-16-2012 16:56   a/b/ 
            0  06-16-2012 16:51   a/b/c/ 
            0  06-16-2012 16:54   a/b/d/ 
            9  06-16-2012 16:54   a/b/d/hello.xml
            0  06-16-2012 16:56   a/b/e
            8  01-20-2012 15:03   some.xml
            0  06-18-2012 09:40   aa/ 
    ---------                     -------
           17                     8 files
    $
    


     
    Hermann <myXsltBlog/> <myXsltTweets/>

    Attachments

    Updated on 2014-03-25T02:53:11Z at 2014-03-25T02:53:11Z by iron-man
  • ansmyke
    ansmyke
    98 Posts

    Re: uploading the directory on XI50

    ‏2012-06-25T19:54:08Z  
    • HermannSW
    • ‏2012-06-18T12:21:02Z
    This is the test archive I used, contains empty directories, a zero size file, a top level file, ...
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">$ unzip -l a.zip Archive: a.zip Length Date Time Name --------- ---------- ----- ---- 0 06-16-2012 16:51 a/ 0 06-16-2012 16:56 a/b/ 0 06-16-2012 16:51 a/b/c/ 0 06-16-2012 16:54 a/b/d/ 9 06-16-2012 16:54 a/b/d/hello.xml 0 06-16-2012 16:56 a/b/e 8 01-20-2012 15:03 some.xml 0 06-18-2012 09:40 aa/ --------- ------- 17 8 files $ </pre>

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Thanks Hermann!
  • ansmyke
    ansmyke
    98 Posts

    Re: uploading the directory on XI50

    ‏2012-06-25T19:55:01Z  
    • swlinn
    • ‏2012-06-15T21:28:15Z
    WAMC would be an option. If doing this on your own, you could write a script that creates a SOMA request for the XML Management Interface that will first do a dp:do-action to create all of your directories and subdirectories from your source and then will do a number of dp:set-files, having read the files and base64 encoded the content of the dp:set-file. I believe there have been threads in the forum on this subject in the past.

    Regards,
    Steve
    Hi Steve! Thanks for the suggestion but my use case SOMA will not serve as we will have to update the file name manually and the schema standards we are using are opensource industry accepted, so we will have to update the file names manually in the scripts, every time we expose new service or a new patch is released.

    Thanks
    Myke
  • ansmyke
    ansmyke
    98 Posts

    Re: uploading the directory on XI50

    ‏2012-06-25T22:31:50Z  
    • irazabal
    • ‏2012-06-16T00:00:53Z
    so here is a example of how to do it, with a combination of perl, and SOMA.
    First you need a shell script to orchestrate the whole thing:
    #!/bin/bash
    1. This script automates a file retrieve session with a DP device.
    2. In this session, it uses DP SOMA commands to send a file to
    3. DP from a local directory on the client.
    #
    ARGS=6
    if ; then
    echo "Usage: dosetfile.sh USER PASS DP_HOSTNAME DP_DOMAIN SERVICE_NAME LOCAL_FILE"
    exit 1
    fi

    dp_user=$1
    dp_pass=$2
    dp_hostname=$3
    dp_domain=$4
    service_name=$5
    local_file=$6
    echo '<?xml version="1.0" encoding="UTF-8"?>' > outfile.xml

    echo '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' >> outfile.xml
    echo ' <soapenv:Body>' >> outfile.xml
    echo ' <dp:request domain="'$dp_domain'" xmlns:dp="http://www.datapower.com/schemas/management">' >> outfile.xml
    echo ' <dp:set-file name="local:///'$service_name'">' >> outfile.xml
    ./encodeFle.pl $local_file >> outfile.xml
    echo '</dp:set-file>' >> outfile.xml
    echo ' </dp:request>' >> outfile.xml
    echo ' </soapenv:Body>' >> outfile.xml
    echo '</soapenv:Envelope>' >> outfile.xml
    curl -v -k -u $dp_user:$dp_pass -d@outfile.xml $dp_hostname/service/mgmt/current

    this one take a file and sends it to a directory in DP, it calls encodeFile.pl:

    #! /usr/bin/perl
    use MIME::Base64;
    use XML::XPath;
    use Data::Dumper;
    my $file = $ARGV[0];
    my $doc = XML::XPath->new(filename => $file);
    foreach my $files ($doc->find('/')->get_nodelist){
    #print (XML::XPath::XMLParser::as_string($files));
    my $encoded = encode_base64(XML::XPath::XMLParser::as_string($files));
    print ($encoded);
    }

    if you also want to create the directory from scratch...use this:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <dp:request domain="default" xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:do-action>
    <CreateDir>
    <Dir>local:///myTestDirectory</Dir>
    </CreateDir>
    </dp:do-action>
    </dp:request>
    </env:Body>
    </env:Envelope>

    not the most straight forward way, but it works...
    Alex
    Thanks Alex very useful.