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.
6 replies Latest Post - ‏2013-02-18T09:59:40Z by SystemAdmin
SystemAdmin
SystemAdmin
6772 Posts
ACCEPTED ANSWER

Pinned topic gzip base64 encoded string and xml messages - How to read in single MPGW

‏2013-02-11T16:12:00Z |
Hi,

Could you please guide how to process gzip base64 encoded string and xml messages in single multiprotocol gateway(MPGW) service. I am looking for following items,

1. What type of action to be used in request rule.
2. Addition configuration needed in MPGW properties.
3. Which client testing tool to be used for sending base64 enccode string messages.
4. Basic code snippet for this.

I will appreciate for valuable answer.

Thank you in Advance
Updated on 2013-02-18T09:59:40Z at 2013-02-18T09:59:40Z by SystemAdmin
  • HermannSW
    HermannSW
    4501 Posts
    ACCEPTED ANSWER

    Re: gzip base64 encoded string and xml messages - How to read in single MPGW

    ‏2013-02-11T16:35:45Z  in response to SystemAdmin
    If you need to process plain base64 encoded gzipped data like this::
    $ gzip -c | base64
    test
    H4sIAJAdGVEAAytJLS7hAgDGNbk7BQAAAA==
    $ 
    $ gzip -c | base64
    <data>text</data>
    H4sIAJYdGVEAA7NJSSxJtCtJrSix0QczuQC6oUhhEgAAAA==
    $
    


    then:
    1. Transform Binary action

    Can you canfirm that above base64 strings is what you input looks like?
    What protocol will be used to access DataPower? (http/MQ/...)

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:40:35Z at 2014-03-25T02:40:35Z by iron-man
    • SystemAdmin
      SystemAdmin
      6772 Posts
      ACCEPTED ANSWER

      Re: gzip base64 encoded string and xml messages - How to read in single MPGW

      ‏2013-02-11T19:30:28Z  in response to HermannSW
      Dear HermannSW,

      Thank you for reply.

      Below mentioned input exactly same I am receiving it and http protocol is used to access DP mpgw service.
      Thanks
      • HermannSW
        HermannSW
        4501 Posts
        ACCEPTED ANSWER

        Re: gzip base64 encoded string and xml messages - How to read in single MPGW

        ‏2013-02-11T23:41:31Z  in response to SystemAdmin
        Hi,

        your MPGW needs to have Non-XML request type.
        The request policy needs a match action (eg. all) and then a Transform Binary action.
        That action references stylesheet b64gz.xsl or b64gzParse.xsl, FFD file String.ffd is needed, too.
        You can store all under local:, for ease of demonstration I have the FFD on a web server and use coproc2 tool.

        This is the refrenced FFD file:
        
        $ cat String.ffd <!-- This FFD converts the input into an XML tree like 
        
        this:   <object> <message>***string data***</message> </object> --> <File name=
        "object"> <Field name=
        'message' type=
        'String'/> </File> $
        


        This is how you can handle strings:
        
        $ echo 
        "test" | gzip -c | base64 | coproc2 b64gz.xsl - http:
        //dp3-l3:2224  test $ $ cat b64gz.xsl <xsl:stylesheet version=
        "1.0" xmlns:xsl=
        "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
        "http://www.datapower.com/extensions" extension-element-prefixes=
        "dp" > <xsl:output omit-xml-declaration=
        "yes"/>   <dp:input-mapping href=
        "http://9.152.4.11/String.ffd" type=
        "ffd"/>   <xsl:template match=
        "/"> <xsl:copy-of select=
        "dp:inflate(., 'gzip')"/> </xsl:template> </xsl:stylesheet> $
        


        And for dealing with XML you just need to add a dp:parse():
        
        $ echo 
        "<data>text</data>" | gzip -c | base64 | coproc2 b64gzParse.xsl - http:
        //dp3-l3:2224 ; echo <data>text</data> $ $ cat b64gzParse.xsl <xsl:stylesheet version=
        "1.0" xmlns:xsl=
        "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
        "http://www.datapower.com/extensions" extension-element-prefixes=
        "dp" > <xsl:output omit-xml-declaration=
        "yes"/>   <dp:input-mapping href=
        "http://9.152.4.11/String.ffd" type=
        "ffd"/>   <xsl:template match=
        "/"> <xsl:copy-of select=
        "dp:parse(dp:inflate(., 'gzip'))"/> </xsl:template> </xsl:stylesheet> $
        


        coproc2 tool uses curl command to send data against DataPower service.
        You may use other tools, or Post.java.

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

          Re: gzip base64 encoded string and xml messages - How to read in single MPGW

          ‏2013-02-13T12:57:19Z  in response to HermannSW
          Dear Hermann,

          Scenario 1:

          I am getting compressed and encoded request from client like this
          "<object><message>dQMAAB+LCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyIev8zqdpnXL+tqlddtkTdHv3HyY4+/pD+ytqiWL7JFfnT89Ondr14+PX5zevfp6fPTN6eP74YN8IoCwu/2j98rvz76yWqWnVfL/PFd70Nu9Lw4z0+up2X+us3a/Oj1m5MUH03x0eO7nW99sNwnmr/I26uqfttY2AYb2/RseV7xBz/2+GleFpd5fQ146+aordfUS+dDafkqb+vrs2Wb15dZebS78/hu+InX6nmxKNqje9pC/pKvDQIvj+Ztu3p09+7ezu54b298b3/88KFFmL4Omr+s6vbowc7Orm3Bn/CQ7DtmTI9fEz7FNG/u8gyY7zdOB5HtRzPxQ5wJ97aTsP8nAAD//1p9mpl1AwAA</message></object>".

          I did following xsl transformation and d:inflate() is not giving any value. Showing syslog error 'Error while inflating data
          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp">
          <xsl:output omit-xml-declaration="yes"/>
          <dp:input-mapping href="local:///String.ffd" type="ffd"/>
          <xsl:template match="/">
          <xsl:variable name="encodeinput">
          <xsl:value-of select="/object/message"/>
          </xsl:variable>
          <xsl:message terminate="no" dp:priority="debug">
          input******<xsl:value-of select="$encodeinput"/>
          inflate******<xsl:copy-of select="dp:inflate($encodeinput,'gzip')"/>
          </xsl:message>
          </xsl:template>
          </xsl:stylesheet>
          Scenario 2:

          When I triggered following request(compressed and encoded) which is generated dp:deflate(.,'gzip'). I can see dp:inflate() return values. XSL tranformation applied for this
          is just reading input and deflate through gzip then inflate again through gzip algorithm.

          "H4sIAAAAAAAAA+yTTU7DMBCF1+UUnCCTpEioyLJU1VlURMUigb0VJsIijStnWpTbY4fgpJFYsmM3fvN5fp5lJpWlFq205oSWNHb8ZsWeXKxIm/agjsi3QsCLFNsyA5HlWZkxuAbcjbGMC0P8iD1/NW+qNi0ymImeyXWNu75qsCBFyItyd+ulyksMFtlZ0aGfpw9In8Z+dKHyOEkg921t/HnFBDb6grb3xc4dJ3t2LRbiAD4j2X7fEtqLangSM7hWJijXR018PQLfpyH701zyd6LTA0AaJ1GaRuu7aLMJs7r0nJbGEr+P4yQAg+KXgcU2rHCj6Ao78K7DZPtvL+C8+jf/j82fbs5+0RcAAAD//wMAvNEn11oDAAA=="
          I can understand compressed string generated by third party tool(internal dot net tool)is differ than dp:deflate().

          Could you please guide why dp:inflate is not return values in Scenario 1 and return values in Scenario 2.
          Thank you in advance.
          • HermannSW
            HermannSW
            4501 Posts
            ACCEPTED ANSWER

            Re: gzip base64 encoded string and xml messages - How to read in single MPGW

            ‏2013-02-14T09:30:44Z  in response to SystemAdmin
            Hi,

            >
            > Scenario 1:
            >
            > I am getting compressed and encoded request from client like this
            > "<object><message>dQMAAB+LCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyIev8zqdpnXL+tqlddtkTdHv3HyY4+/pD+ytqiWL7JFfnT89Ondr14+PX5zevfp6fPTN6eP74YN8IoCwu/2j98rvz76yWqWnVfL/PFd70Nu9Lw4z0+up2X+us3a/Oj1m5MUH03x0eO7nW99sNwnmr/I26uqfttY2AYb2/RseV7xBz/2+GleFpd5fQ146+aordfUS+dDafkqb+vrs2Wb15dZebS78/hu+InX6nmxKNqje9pC/pKvDQIvj+Ztu3p09+7ezu54b298b3/88KFFmL4Omr+s6vbowc7Orm3Bn/CQ7DtmTI9fEz7FNG/u8gyY7zdOB5HtRzPxQ5wJ97aTsP8nAAD//1p9mpl1AwAA</message></object>".
            > ...
            > ...
            > Scenario 2:
            >
            > When I triggered following request(compressed and encoded) which is generated dp:deflate(.,'gzip'). I can see dp:inflate() return values. XSL tranformation applied for this
            > is just reading input and deflate through gzip then inflate again through gzip algorithm.
            >
            > "H4sIAAAAAAAAA+yTTU7DMBCF1+UUnCCTpEioyLJU1VlURMUigb0VJsIijStnWpTbY4fgpJFYsmM3fvN5fp5lJpWlFq205oSWNHb8ZsWeXKxIm/agjsi3QsCLFNsyA5HlWZkxuAbcjbGMC0P8iD1/NW+qNi0ymImeyXWNu75qsCBFyItyd+ulyksMFtlZ0aGfpw9In8Z+dKHyOEkg921t/HnFBDb6grb3xc4dJ3t2LRbiAD4j2X7fEtqLangSM7hWJijXR018PQLfpyH701zyd6LTA0AaJ1GaRuu7aLMJs7r0nJbGEr+P4yQAg+KXgcU2rHCj6Ao78K7DZPtvL+C8+jf/j82fbs5+0RcAAAD//wMAvNEn11oDAAA=="
            >
            >
            > I can understand compressed string generated by third party tool(internal dot net tool)is differ than dp:deflate().
            >
            > Could you please guide why dp:inflate is not return values in Scenario 1 and return values in Scenario 2.
            >
            >
            whatever you get from client in Scenario 1, it is not gzip compressed -- at least that is what "gunzip" tool says, see below.
            Find out what your client is sending, if that is "gzipped", "compressed" or "deflated", then DataPower can process.
            
            $ echo 
            "dQMAAB+LCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyIev8zqdpnXL+tqlddtkTdHv3HyY4+/pD+ytqiWL7JFfnT89Ondr14+PX5zevfp6fPTN6eP74YN8IoCwu/2j98rvz76yWqWnVfL/PFd70Nu9Lw4z0+up2X+us3a/Oj1m5MUH03x0eO7nW99sNwnmr/I26uqfttY2AYb2/RseV7xBz/2+GleFpd5fQ146+aordfUS+dDafkqb+vrs2Wb15dZebS78/hu+InX6nmxKNqje9pC/pKvDQIvj+Ztu3p09+7ezu54b298b3/88KFFmL4Omr+s6vbowc7Orm3Bn/CQ7DtmTI9fEz7FNG/u8gyY7zdOB5HtRzPxQ5wJ97aTsP8nAAD//1p9mpl1AwAA" | base64 -di | gunzip -   gzip: stdin: not in gzip format $ $ echo 
            "H4sIAAAAAAAAA+yTTU7DMBCF1+UUnCCTpEioyLJU1VlURMUigb0VJsIijStnWpTbY4fgpJFYsmM3fvN5fp5lJpWlFq205oSWNHb8ZsWeXKxIm/agjsi3QsCLFNsyA5HlWZkxuAbcjbGMC0P8iD1/NW+qNi0ymImeyXWNu75qsCBFyItyd+ulyksMFtlZ0aGfpw9In8Z+dKHyOEkg921t/HnFBDb6grb3xc4dJ3t2LRbiAD4j2X7fEtqLangSM7hWJijXR018PQLfpyH701zyd6LTA0AaJ1GaRuu7aLMJs7r0nJbGEr+P4yQAg+KXgcU2rHCj6Ao78K7DZPtvL+C8+jf/j82fbs5+0RcAAAD//wMAvNEn11oDAAA==" | base64 -di | gunzip - base64: invalid input <PartnerProperties> <OperationName>ADD/UPDATE/DELETE</OperationName> <Partner> <PartnerKey>Vodafone</PartnerKey> <LifeCycleState>STC Lifecycle</LifeCycleState> <PartnerName>STC Networks</PartnerName> <PartnerInfo> <DeliveryStatus>true</DeliveryStatus> <RetryInterval>10</RetryInterval> <RetryLimit>3</RetryLimit> <PartnerIP>http:
            //201.22.34.99</PartnerIP> <PartnerPort>7001</PartnerPort> </PartnerInfo> <Services/> </Partner> <Partner> <PartnerKey>STC</PartnerKey> <LifeCycleState>STC Lifecycle</LifeCycleState> <PartnerName>STC Networks</PartnerName> <PartnerInfo> <DeliveryStatus>true</DeliveryStatus> <RetryInterval>10</RetryInterval> <RetryLimit>3</RetryLimit> <PartnerIP>http:
            //201.22.34.99</PartnerIP> <PartnerPort>7001</PartnerPort> </PartnerInfo> <Services/> </Partner> </PartnerProperties> $
            


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

              Re: gzip base64 encoded string and xml messages - How to read in single MPGW

              ‏2013-02-18T09:59:40Z  in response to HermannSW
              Thank you for great help..