Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
13 replies Latest Post - ‏2013-11-03T16:47:41Z by letakeda
letakeda
letakeda
20 Posts
ACCEPTED ANSWER

Pinned topic Set-file not working

‏2013-10-29T19:19:40Z |

Hi All,

I'm trying to upload this file to DataPower, but this is not working. I'm doing the same thing with get-file and it's working fine, however the set-file is not.

What am I doing wrong here? Is there any way I can enable any log for this to get more details? Any help would be helpful! Thanks!

XML:

$ cat requestToSet.xml 
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dp:request xmlns:dp="http://www.datapower.com/schemas/management">
<dp:set-file name="local:///Test.xml">        
Test.xml
</dp:set-file>
</dp:request>
</soapenv:Body>
</soapenv:Envelope>

CURL:

CURL="/home/admin/programs/curl/bin/curl"; CURLIBS="/home/admin/programs/curl/lib"; export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CURLIBS};

$CURL -k --data-bin @requestToSet.xml -H "Content-Type: text/xml" -u <user>:<passwd> https://<url>:5550

  • Kumar_Y
    Kumar_Y
    212 Posts
    ACCEPTED ANSWER

    Re: Set-file not working

    ‏2013-10-29T19:22:12Z  in response to letakeda

    This file <dp:set-file name="local:///Test.xml">Test.xml ( This has to be base64 encoded value)</dp:set-file>

    What error are you getting?

    • letakeda
      letakeda
      20 Posts
      ACCEPTED ANSWER

      Re: Set-file not working

      ‏2013-10-29T19:25:42Z  in response to Kumar_Y

      Ops, I missed the most important part:

      This is what I'm receiving back:

      <?xml version="1.0" encoding="UTF-8"?>
      <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>Internal Error (from client)</faultstring></env:Fault></env:Body></env:Envelope>

      I've tried also with:

      "Base64_encoded_File"

      I got the example from: http://www.redbooks.ibm.com/redpapers/pdfs/redp4446.pdf

      • Kumar_Y
        Kumar_Y
        212 Posts
        ACCEPTED ANSWER

        Re: Set-file not working

        ‏2013-10-29T19:36:38Z  in response to letakeda

        I believe you have directly cut, copy and pasted the example from the redbook? If you did, make sure that you are doing the proper editing with tidyxml or any xml tool

        <?xml version="1.0" encoding="UTF-8"?>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Body>
        <dp:request xmlns:dp="http://www.datapower.com/schemas/management">
        <dp:set-file name="local:///Testfile">IFRoaXMgaXMganVzdCB0aGUgdGVzdAo=</dp:set-file>
        </dp:request>
        </soapenv:Body>
        </soapenv:Envelope>
        Also since you are not specifying the domain, it's will automatically takes default domain...
        • letakeda
          letakeda
          20 Posts
          ACCEPTED ANSWER

          Re: Set-file not working

          ‏2013-10-30T13:29:13Z  in response to Kumar_Y

          I've validated it with tinyxml and still the same error.

          Any other idea? is there anything I can check in DataPower that could be maybe blocking it?

          I have no more ideas.

          Thanks!

          • kenhygh
            kenhygh
            1461 Posts
            ACCEPTED ANSWER

            Re: Set-file not working

            ‏2013-10-30T13:32:22Z  in response to letakeda

            use a small dummy file and attach your XML.

            • letakeda
              letakeda
              20 Posts
              ACCEPTED ANSWER

              Re: Set-file not working

              ‏2013-10-30T13:35:30Z  in response to kenhygh

              Can you give me an example please, Ken?

              • Kumar_Y
                Kumar_Y
                212 Posts
                ACCEPTED ANSWER

                Re: Set-file not working

                ‏2013-10-30T13:39:38Z  in response to letakeda

                I haven't tested this, but it should work

                <?xml version="1.0" encoding="UTF-8"?>
                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                <soapenv:Body>
                <dp:request domain="default" xmlns:dp="http://www.datapower.com/schemas/management">
                <dp:set-file name="local:///t.xml">IFRoaXMgaXMganVzdCB0aGUgdGVzdAo=</dp:set-file>
                </dp:request>
                </soapenv:Body>
                </soapenv:Envelope>

                You can use this for reference

                https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014613570

                Also are you using curl command like this?

                curl -k -u user:password -d@filename.xml https://DPhostname:5550/service/mgmt/current

                Updated on 2013-10-30T13:43:53Z at 2013-10-30T13:43:53Z by Kumar_Y
                • swlinn
                  swlinn
                  1346 Posts
                  ACCEPTED ANSWER

                  Re: Set-file not working

                  ‏2013-10-31T20:09:16Z  in response to Kumar_Y

                  Kumar's sample should work (the base64 decode of his data being 'This is just a test')).  As an aside, I've infrequently seen issues with curl when using the -d option.  To be on the safe side, I always use --data-binary, which always works with -d could cause issues.

                  Regards,

                  Steve

                  • letakeda
                    letakeda
                    20 Posts
                    ACCEPTED ANSWER

                    Re: Set-file not working

                    ‏2013-11-01T12:52:55Z  in response to swlinn

                    Hey all,

                    I'm able to download the file, transform it to XML and upload it back to DataPower, however.... I can see a test file there.

                    Here is what I'm doing:

                    CURL="/home/admin/programs/curl/bin/curl"; CURLIBS="/home/admin/programs/curl/lib"; export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CURLIBS};
                     
                    $CURL -k --data-bin @requestToGet.xml -H "Content-Type: text/xml" -u <user>:<password> https://<host>:5550 > base64result
                     
                    transformToXML.pl base64result > XMLresult
                     
                    perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' < XMLresult > Test.xml
                     
                    # Run CURL to set the file
                    $CURL -k --data-bin @requestToSet.xml -u <user>:<password> https://<host>:5550

                    The perl code transfer from base64 to XML.
                    However after I upload the file, and open it in DataPower it contain: "This is just the test"

                    See the screenshots attached.

                    requestToGet.xml:

                    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
                     <env:Body>
                     <dp:request xmlns:dp="http://www.datapower.com/schemas/management">
                     <dp:get-file name="local://TestGet.xml"/>
                     </dp:request>
                     </env:Body>
                    </env:Envelope>

                    requestToSet.xml

                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                       <soapenv:Body>
                          <dp:request domain="default" xmlns:dp="http://www.datapower.com/schemas/management">
                             <dp:set-file name="local:///Test.xml">IFRoaXMgaXMganVzdCB0aGUgdGVzdAo=</dp:set-file>
                          </dp:request>
                       </soapenv:Body>
                    </soapenv:Envelope>
                    • kenhygh
                      kenhygh
                      1461 Posts
                      ACCEPTED ANSWER

                      Re: Set-file not working

                      ‏2013-11-01T14:49:09Z  in response to letakeda

                      And what did you expect? That's what your requestToSet.xml told DataPower to do.

                      • letakeda
                        letakeda
                        20 Posts
                        ACCEPTED ANSWER

                        Re: Set-file not working

                        ‏2013-11-01T14:53:45Z  in response to kenhygh

                        I'm sending the same file I downladed and file is like this:

                        <aaa:AAAInfo xmlns:aaa="http://www.datapower.com/AAAInfo"><aaa:FormatVersion>1</aaa:FormatVersion><aaa:Filename>local:///AAA-Mvno.xml</aaa:Filename><aaa:Summary/><!-- Determine credential from output of the extract-identity phase. --><!-- Specify credential (if any) to use when there is no authenticated identity. --><!-- Map credentials to different credentials. --><!-- Determine resource from output of the extract-resource phase. --><!-- Authorize access to resource for credentials. --><aaa:Authorize><aaa:InputCredential>C=US, O=Sprint, OU=Projects, OU=BMP, OU=TPA, CN=wsi-test-01</aaa:InputCredential><aaa:InputResource>\A\d{1,10}\z</aaa:InputResource><aaa:Access>allow</aaa:Access></aaa:Authorize><aaa:Authorize><aaa:InputCredential>C=us, O=Sprint, OU=Projects, OU=BMP, OU=TPA, CN=wsi-02</aaa:InputCredential><aaa:InputResource>\A\d{1,10}\z</aaa:InputResource><aaa:Access>allow</aaa:Access></aaa:Authorize></aaa:AAAInfo>

                        • kenhygh
                          kenhygh
                          1461 Posts
                          ACCEPTED ANSWER

                          Re: Set-file not working

                          ‏2013-11-01T15:00:55Z  in response to letakeda

                          requestToSet.xml does not send that content. It sends ' This is just the test'.

                          In this xml, you have:

                          <dp:set-file name="local:///Test.xml">IFRoaXMgaXMganVzdCB0aGUgdGVzdAo=</dp:set-file>

                          the contents of this element is the base64-encoded content of the file you're uploading. If you base64 decode IFRoaXMgaXMganVzdCB0aGUgdGVzdAo= you get ' This is just the test'.

                          If you're going to do this, just as you had to 1) get the file, 2) extract the base64-encode from its containing XML, and 3) decode the base64.

                          To upload, you'll have to take something similar. 1) base64-encode the file, 2) wrap it with the required XML, and 3) send it to DataPower.

                          Updated on 2013-11-01T15:03:09Z at 2013-11-01T15:03:09Z by kenhygh
                          • letakeda
                            letakeda
                            20 Posts
                            ACCEPTED ANSWER

                            Re: Set-file not working

                            ‏2013-11-03T16:47:41Z  in response to kenhygh

                            Understood now! Thanks so much! It worked! Appreciated!