Topic
93 replies Latest Post - ‏2014-12-19T09:49:41Z by HermannSW
HermannSW
HermannSW
4359 Posts
ACCEPTED ANSWER

Pinned topic coproc2

‏2011-03-06T23:43:43Z |
Hello,

with announcement Deprecated features in the 3.8.0 IBM WebSphere DataPower SOA Appliances products the coprocessor features (with xa.jar) has been deprecated.
It is still part of even 3.8.2.x firmware though.
Coprocessor mode allows for transparent execution of XSLT transformations on DataPower in Java environments by xa.jar.
In short the stylesheet and xmlfile are sent to DataPower appliance, the stylesheet gets compiled if not already in stylesheet cache,
is then applied to the xmlfile as input and returns the response generated by DataPower to the Java application.

While this is useful for processing it definitely is also useful for development and testing of stylesheets without always having to upload the stylesheets to the appliance explicitely.
(as you know processing of stylesheets making use of DataPower extension functions is not possible by other XSLT processors)

The recommended alternative from deprecation announcement was "Use HTTP loopback".

Find attached DataPower service coproc2.zip, it does allow for
  • processing of received xmlfile by received stylesheet on DataPower appliance
  • because it is a MPGW it also may be used on XB60 and XM70 models which never provided coproc support.

The service export was generated with firmware 3.7.3.15.
I successfully imported it on 3.8.0, 3.8.1 and 3.8.2 boxes.
Hermann<myXsltBlog/>

Attachments

Updated on 2013-03-21T09:40:27Z at 2013-03-21T09:40:27Z by HermannSW
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2011-03-07T00:04:33Z  in response to HermannSW
    coproc2 service
    • static backend "http://1.2.3.4"
    • request type: xml
    • reponse tye: does not matter because of skip-backside
    • HTTP FSH on port 2223

    Its policy consists of
    • match all
    • a first transform action from NULL to NULL with "local:///coproc2.xsl"
    • a second transform action from INPUT to OUTPUT with "xsl"
    If you try to create the 2nd transform in wizard it does not allow to specify context "xsl" for the transform.
    Select eg. store:///identity.xsl first and then change that in the Object screen of the MPGW later, or use CLI.

    This is stylesheet coproc2.xsl (also attached):
    
    <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 method=
    "xml" omit-xml-declaration=
    "yes"/> <xsl:template match=
    "/"> <dp:set-variable name=
    "'var://context/xsl'" value=
    "dp:inflate(dp:http-request-header('xsl'),'gzip')"/>   <dp:set-variable name=
    "'var://service/mpgw/skip-backside'" value=
    "1"/> </xsl:template>   </xsl:stylesheet>
    


    It first does a "gunzip" of the received base64 encoded gzipped stylesheet found in HTTP header "xsl".
    Then it stores the stylesheet in context "xsl" for use as stylesheet by 2nd transformation.

    After that it sets skip-backside to 1 which makes the MPGW a loopback service.

    After that the 2nd transformation uses the stylesheet from context "xsl" to read and process the xmlfile data and send response back.

    Hermann<myXsltBlog/>
    • HermannSW
      HermannSW
      4359 Posts
      ACCEPTED ANSWER

      Re: coproc2

      ‏2011-03-07T00:13:21Z  in response to HermannSW
      Now what is missing is a client which sends a base64 encoded gzipped stylesheet as HTTP header "xsl" in addition to the xmlfile.

      This is what attached shell script coproc2 does (also attached, works for Linux or Cygwin under Windows):
      #!/bin/bash
      curl -H "xsl: `gzip -c $1 | base64 | sed -e :a -e '/.*[^\.]$/N;s/\n//;ba'`" --data-binary @$2 $3
      


      The format is:
      coproc2 stylesheet xmlfile coproc2endpoint

      The sed statement just removes all whitespace from the base64 encoded gzipped stylesheet.
      The "xsl" HTTP header is set via the "-H" option of curl.
      The xmlfile is sent by "--data-binary" option.

      Hermann <myXsltBlog/>

      Attachments

      Updated on 2014-03-25T03:34:07Z at 2014-03-25T03:34:07Z by iron-man
      • HermannSW
        HermannSW
        4359 Posts
        ACCEPTED ANSWER

        Re: coproc2

        ‏2011-03-07T00:20:16Z  in response to HermannSW
        Let's take this stylesheet coproc2.xsl (also attached) as sample:
        <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" />
         
          <xsl:template match="/">
            <xsl:value-of select="dp:radix-convert(dp:encode(.,'base-64'),64,16)"/>
          </xsl:template>
         
        </xsl:stylesheet>
        


        Because it makes use of DataPower extension function dp:radix-convert() it cannot be processed by other XSLT processors.

        The sample xmlfile is:
        <some>test</some>
        


        So 2hex.xsl just takes the string "test", encodes it as base64 string, and then converts that to hexadecimal.
        The hexadecimal representation of "test" is "74657374" as can be seen by this execution:
        $ coproc2 2hex.xsl some.xml http://dp3-l3.boeblingen.de.ibm.com:2223; echo
        74657374
        $
        


        Hermann <myXsltBlog/>

        Attachments

        Updated on 2014-03-25T03:34:02Z at 2014-03-25T03:34:02Z by iron-man
        • HermannSW
          HermannSW
          4359 Posts
          ACCEPTED ANSWER

          Re: coproc2

          ‏2011-03-07T00:36:03Z  in response to HermannSW
          Just before posting coproc2 service I thought on a client for Windows environments without cygwin.
          And because the shell script made use of curl, gzip, base64 and sed commands, I tried to come up with a single file solution.

          It turned out that SOAPClient4XG from 2001 developerWorks article A simple SOAP client was pretty close.
          It is a Java client capable of sending SOAP requests and receiving and displaying the corresponding response.

          I just needed to add the base64 encoded gzipped stylesheet as "xsl" HTTP header.

          This is the main addition to SOAPClient4XG I did (from attached complete coproc2.java):
          
          ... 
          // Read stylesheet2send into b2[] InputStream fin2 = 
          
          new FileInputStream(stylesheet2Send); ByteArrayOutputStream bout2 = 
          
          new ByteArrayOutputStream(); copy(fin2,bout2); fin2.close();   
          
          byte b2[] = bout2.toByteArray();   
          // B[] = gzip(b2[]) ByteArrayOutputStream bos = 
          
          new ByteArrayOutputStream(); GZIPOutputStream gz = 
          
          new GZIPOutputStream(bos); gz.write(b2); gz.close(); bos.close();   
          
          byte B[] = bos.toByteArray();   
          // base64 encoding characters 
          
          static 
          
          final 
          
          char b64[] = 
          { 
          'A',
          'B',
          'C',
          'D',
          'E',
          'F',
          'G',
          'H',
          'I',
          'J',
          'K',
          'L',
          'M', 
          'N',
          'O',
          'P',
          'Q',
          'R',
          'S',
          'T',
          'U',
          'V',
          'W',
          'X',
          'Y',
          'Z', 
          'a',
          'b',
          'c',
          'd',
          'e',
          'f',
          'g',
          'h',
          'i',
          'j',
          'k',
          'l',
          'm', 
          'n',
          'o',
          'p',
          'q',
          'r',
          's',
          't',
          'u',
          'v',
          'w',
          'x',
          'y',
          'z', 
          '0',
          '1',
          '2',
          '3',
          '4',
          '5',
          '6',
          '7',
          '8',
          '9',
          '+',
          '/' 
          }; 
          
          static 
          
          final 
          
          char pad = 
          '=';   
          // strb64 = base64(B[]) ByteArrayOutputStream bos2 = 
          
          new ByteArrayOutputStream(); 
          
          int i; 
          
          for(i=0; i<B.length-2; i+=3) 
          { bos2.write(b64[  ((
          
          int)B[i+0]&0xFF)      >>2 ]); bos2.write(b64[((((
          
          int)B[i+0]&0xFF)&0x03)<<4) | (((
          
          int)B[i+1]&0xFF)      >>4)]); bos2.write(b64[((((
          
          int)B[i+1]&0xFF)&0x0F)<<2) | (((
          
          int)B[i+2]&0xFF)      >>6)]); bos2.write(b64[  ((
          
          int)B[i+2]&0xFF)&0x3F     ]); 
          } 
          
          if (i < B.length) 
          { bos2.write(b64[  ((
          
          int)B[i+0]&0xFF)      >>2 ]);   
          
          if (i+2 == B.length) 
          { bos2.write(b64[((((
          
          int)B[i+0]&0xFF)&0x03)<<4) | (((
          
          int)B[i+1]&0xFF)      >>4)]); bos2.write(b64[((((
          
          int)B[i+1]&0xFF)&0x0F)<<2)]); 
          } 
          
          else 
          { bos2.write(b64[((((
          
          int)B[i+0]&0xFF)&0x03)<<4)]); bos2.write(pad); 
          } bos2.write(pad); 
          } bos2.close();   String strb64 = bos2.toString(); ...
          


          It was surprising to me that Java does provide gzip-capabilities, but does not support base64 encoding ...
          And dealing with byte indexes was not that easy because Java byte type is signed.

          Find here previous sample processed by Java client:
          
          $ java coproc2 2hex.xsl some.xml http:
          //dp3-l3.boeblingen.de.ibm.com:2223 74657374 $
          


          Hermann<myXsltBlog/>
          • HermannSW
            HermannSW
            4359 Posts
            ACCEPTED ANSWER

            Re: coproc2

            ‏2011-03-07T00:49:15Z  in response to HermannSW
            Some words on the efficient DataPower SHA1 stylesheet caching.

            When sending a stylesheet for the first time to DataPower with one of the clients, it gets compiled and put into stylesheet cache.
            You may see this by first log entry at "information" level logging:
            
            mpgw (coproc2): rule (coproc2_rule_1): #1 xform: 
            'Transforming NULL with local:///coproc2.xsl results stored in NULL' completed OK.
            

            Second log entry:
            
            xmlmgr (
            
            default): xslt Compilation Request: Compilation complete of URL xa35:
            //tmp/temp_01442
            


            Now if the same stylesheet is received, DataPower computes the SHA1 value of it, detects the cached version and uses that without compilation.
            First log entry:
            
            mpgw (coproc2): rule (coproc2_rule_1): #1 xform: 
            'Transforming NULL with local:///coproc2.xsl results stored in NULL' completed OK.
            

            Second log entry:
            
            xmlmgr (
            
            default): xa35:
            //tmp/temp_01458 has identical SHA1 hash to xa35://tmp/temp_01131; using cached version.
            


            Because of the SHA1 stylesheet cache coproc2 service is pretty performant.

            Hermann<myXsltBlog/>
            • HermannSW
              HermannSW
              4359 Posts
              ACCEPTED ANSWER

              Re: coproc2

              ‏2011-03-07T02:12:45Z  in response to HermannSW
              Oops!

              After rearranging the source before posting I did work with 1.6 JDK only.
              Above attached coproc2.java does not compile with 1.4 and 1.5 JDK.

              Just removing "static" makes it compile and work for 1.4 and 1.5 JDK.
              74c74
              <     static final char b64[] = {
              ---
              >     final char b64[] = {
              81c81
              <     static final char pad = '=';
              ---
              >     final char pad = '=';
              

              Hermann <myXsltBlog/>
              Updated on 2014-03-25T03:33:57Z at 2014-03-25T03:33:57Z by iron-man
              • HermannSW
                HermannSW
                4359 Posts
                ACCEPTED ANSWER

                Re: coproc2

                ‏2011-03-07T02:31:39Z  in response to HermannSW
                Combined screenshot of Linux/Cygwin/Windows coproc2 executions:
                https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/coproc210
                Hermann<myXsltBlog/>
                • HermannSW
                  HermannSW
                  4359 Posts
                  ACCEPTED ANSWER

                  Re: coproc2

                  ‏2011-03-10T11:08:40Z  in response to HermannSW
                  Posting "xs:decimal()" may be interesting as it shows that having more than one coproc2 service may
                  make sense if needing different XML Manager settings for execution ("XSLT 2.0" in posting):
                  https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/xs_decimal19?lang=en

                  That means "coproc2 stylesheet xmlfile coproc2endpoint" really allows for changing all three arguments.
                  Hermann<myXsltBlog/>
                  • Jaango
                    Jaango
                    266 Posts
                    ACCEPTED ANSWER

                    Re: coproc2

                    ‏2011-03-16T15:02:05Z  in response to HermannSW
                    Hermann,

                    Do we have to install/add any components to cygwin, in case we want to use gzip, base64 and sed commands. If so, could you please share any links.I will try with the java client as well, that you have mentioned. This can save a lot of time during development activities.
                    • HermannSW
                      HermannSW
                      4359 Posts
                      ACCEPTED ANSWER

                      Re: coproc2

                      ‏2011-03-16T15:56:38Z  in response to Jaango
                      Maneesh,

                      > Do we have to install/add any components to cygwin, in case we want to use gzip, base64 and sed commands.
                      > If so, could you please share any links.
                      I think gzip, base64 and sed commands are part of basic cygwin setup.
                      If not just start setup again, select any download server, and when seeing the package selection screen just type in eg. "base64" in search field.
                      This will display only those packages where "base64" is contained.
                      Open any of these, change "base64" from "Skip" to "install" and then finish install.

                      In case of trouble you may execute these commands and compare with my outputs:
                      $ which coproc2
                      ~/bin/coproc2
                      $ which curl
                      /usr/bin/curl
                      $ which gzip
                      /usr/bin/gzip
                      $ which base64
                      /usr/bin/base64
                      $ which sed
                      /bin/sed
                      $
                      


                      But the easiest solution is to use the Java client as that contains everything and is functionally equivalent.
                      (This was the reason that I decided to implement base64 encoding myself instead of using available but separately to install packages)

                      > I will try with the java client as well, that you have mentioned. This can save a lot of time during development activities.
                      Yes!

                       
                      Hermann <myXsltBlog/>
                      Updated on 2014-03-25T03:33:53Z at 2014-03-25T03:33:53Z by iron-man
                    • Jaango
                      Jaango
                      266 Posts
                      ACCEPTED ANSWER

                      Re: coproc2

                      ‏2011-03-16T16:33:28Z  in response to Jaango
                      Hi Hermann,

                      I am not sure why I am getting the below error. Do u have any thoughts. I used command prompt and placed all the files including coproc2.java in D:drive and got the below.

                      D:\>java coproc2 2hex.xsl some.xml http://boxname:2223
                      Exception in thread "main" java.lang.NoClassDefFoundError: coproc2
                      Caused by: java.lang.ClassNotFoundException: coproc2
                      at java.net.URLClassLoader$1.run(Unknown Source)
                      at java.security.AccessController.doPrivileged(Native Method)
                      at java.net.URLClassLoader.findClass(Unknown Source)
                      at java.lang.ClassLoader.loadClass(Unknown Source)
                      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
                      at java.lang.ClassLoader.loadClass(Unknown Source)
                      Could not find the main class: coproc2. Program will exit.
      • HermannSW
        HermannSW
        4359 Posts
        ACCEPTED ANSWER

        Re: coproc2 / export-coproc2all.zip

        ‏2013-11-22T21:30:02Z  in response to HermannSW

        OK,

        we had two coproc2 service flavors sofar

        • for processing XML with stylesheet (port 2223)
        • for processing Non-XML with Transform Binary stylesheet (port 2224)


        With firmware version 6.0.0.0 two new types of processing are available in DataPower:

        • XQuery 1.0, allows to query/transform XML, comprises XPath 2.0 (DataPower had XPath 1.0 sofar)
        • JSONiq Extension to XQuery, allows to directly process JSON without having to convert to JSONX first


        I thought it is the time now to make all 4 transformations available in one service export
        (you may import into application domain, or into default domain -- your choice).

        Find attached service export  export-coproc2all.zip, that contains 4 MPGWs with each having its own XML manager:

        • port 2223: XSLT processing XML
        • port 2224: Transform Binary XSLT processing Non-XML
        • port 2225: XQuery processing XML
        • port 2226: JSONiq processing JSON


        Here you can see the brave new world, all sample files are attached too:
        (of course you can provide input files as 2nd argument instead of "-" which just takes data from standard input)

        $ echo '<x>1</x>' | coproc2 double.xsl - http://firestar:2223 ; echo
        <out><x>1</x><x>1</x></out>
        $
        $ echo -ne "te\x0t" | coproc2 toHex.xsl - http://firestar:2224 ; echo
        74650074
        $
        $ echo '<a><b><c/></b></a>' | coproc2 xml2xml.xq - http://firestar:2225 ; echo
        <?xml version="1.0" encoding="UTF-8"?>
        <c/><b><c/></b><a><b><c/></b></a>
        $
        $ echo '["a",1,"b"]' | coproc2 json2json.xq - http://firestar:2226 ; echo

        [
          "b",
          1,
          "a"
        ]
        $


        As you have seen, you could just use the "old" coproc2 bash client.

        Of course you can use the "old" Java client, too (coproc2.class has to reside somewhere in $CLASSPATH directories:

        $ echo '<x>1</x>' | java coproc2 double.xsl - http://firestar:2223 ; echo
        <out><x>1</x><x>1</x></out>
        $
        $ echo -ne "te\x0t" | java coproc2 toHex.xsl - http://firestar:2224 ; echo
        74650074
        $
        $ echo '<a><b><c/></b></a>' | java coproc2 xml2xml.xq - http://firestar:2225 ; echo
        <?xml version="1.0" encoding="UTF-8"?>
        <c/><b><c/></b><a><b><c/></b></a>
        $
        $ echo '["a",1,"b"]' | java coproc2 json2json.xq - http://firestar:2226 ; echo

        [
          "b",
          1,
          "a"
        ]
        $

         

        For completeness the small sample scripts:

        $ cat json2json.xq
        declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

        declare option jsoniq-version "0.4.42";
        declare option output:method "json";

        [
          fn:reverse(
            jn:members(.)
          )
        ]
        $
        $ cat xml2xml.xq
        fn:reverse(//*)
        $
        $ cat toHex.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"
        >
          <dp:input-mapping  href="store:///pkcs7-convert-input.ffd" type="ffd"/>

          <xsl:output omit-xml-declaration="yes" />
            
          <xsl:template match="/">
            <xsl:variable name="input64"
              select="dp:binary-encode(/object/message/node())"
            />
            <xsl:value-of
              select="substring(dp:radix-convert(concat('////',$input64), 64, 16), 7)"
            />
          </xsl:template>
         
        </xsl:stylesheet>
        $
        $ cat double.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" />
            
          <xsl:template match="/">
           <out>
            <xsl:copy-of select="."/>
            <xsl:copy-of select="."/>
           </out>
          </xsl:template>
         
        </xsl:stylesheet>
        $

         


        Btw, I will do some Blog postings on JSONiq soon, with another cool tool ...


        Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

        Attachments

        Updated on 2013-11-22T21:38:08Z at 2013-11-22T21:38:08Z by HermannSW
        • HermannSW
          HermannSW
          4359 Posts
          ACCEPTED ANSWER

          Re: coproc2 / export-coproc2all.zip

          ‏2014-01-15T16:04:00Z  in response to HermannSW

          In case of compile erorrs it would be nice to get the DataPower error message back in response. This would remove the need to inspect DataPower log while working with coproc2all services.

          This is not part of export-coporc2all.zip attached above, but you can simply add an error rule matching all with a xform action from INPUT to OUTPUT with the following stylesheet erro.xsl (attached) to the services you are interested in:

          $ cat erro.xsl
          <!DOCTYPE xsl:stylesheet [ <!ENTITY LF "<xsl:text>&#10;</xsl:text>"> ]>
          <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:template match="/">
              <return>&LF;
                <error-code>
                  <xsl:value-of select="dp:variable('var://service/error-code')"/>
                </error-code>&LF;
                <error-subcode>
                  <xsl:value-of select="dp:variable('var://service/error-subcode')"/>
                </error-subcode>&LF;
                <error-message>&LF;
                  <xsl:value-of select="dp:variable('var://service/error-message')"/>&LF;
                </error-message>&LF;
                <formatted-error-message>&LF;
                  <xsl:value-of select="dp:variable('var://service/formatted-error-message')"/>
                  &LF;
                </formatted-error-message>&LF;
              </return>&LF;
            </xsl:template>
           
          </xsl:stylesheet>
          $

           

          Let us take IBAN.xq from yesterday's forum posting as an example:
          https://www.ibm.com/developerworks/community/forums/html/topic?id=202a9f3d-366b-47c7-96e1-aea14473745f#86fc53d1-a639-4bc2-b269-d41c78d06eff

          I just deleted one parenthesis resulting in a XQuery compile error:

          $ diff IBAN.xq e.xq
          29c29
          <       return if ($n > 64)
          ---
          >       return if $n > 64)
          $


          This is the error output returned when trying bad e.xq:

          $ coproc2 IBAN.xq IBAN.xml dp0-l3:2225 ; echo
          true
          $
          $ coproc2 e.xq IBAN.xml dp0-l3:2225 ; echo
          <?xml version="1.0" encoding="UTF-8"?>
          <return>
          <error-code>0x00c30002</error-code>
          <error-subcode>0x00c30002</error-subcode>
          <error-message>
          Fatal Error at /temp_00169:29: [XPST0003] An expression is not a valid instance of the grammar defined for XQuery.
          Column 18, Error detected at token: "$" (DOLLAR)
          Expected (  FLWORExpr |  QuantifiedExpr |  TypeswitchExpr |  IfExpr |  OrExpr )
          </error-message>
          <formatted-error-message>
          &lt;?xml version="1.0" encoding="UTF-8"?>
          &lt;env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">&lt;env:Body>&lt;env:Fault>&lt;faultcode>env:Client&lt;/faultcode>&lt;faultstring>Internal Error (from client)&lt;/faultstring>&lt;/env:Fault>&lt;/env:Body>&lt;/env:Envelope>
          </formatted-error-message>
          </return>

          $


          Happy developing/debugging with coproc2all,

          Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>

          Attachments

      • KSeeker
        KSeeker
        56 Posts
        ACCEPTED ANSWER

        Re: coproc2

        ‏2014-12-04T16:52:13Z  in response to HermannSW

        Hermann - to refer to your comments "This is what attached shell script coproc2 does (also attached, works for Linux or Cygwin under Windows): " - will this file coproc2 work in windows. I get the error as unrecognized internal or external command. I am executing it from the directory I have save it on. Thanks  

        • JimRussell
          JimRussell
          39 Posts
          ACCEPTED ANSWER

          Re: coproc2

          ‏2014-12-04T20:08:03Z  in response to KSeeker

          You really don't need the full Cygwin setup for this.  You really only need a couple of Windows utilities.

          curl.exe - get it from http://curl.haxx.se/download.html

          base64.exe - get it from http://www.fourmilab.ch/webtools/base64/

          tr.exe (to remove end-of-line characters) - I recommend the UnxUtils package for this: http://unxutils.sourceforge.net/

          Once you have those three programs in your PATH, you can create a Windows .BAT file called coproc2.bat that does the same thing as the bash script:

          @echo off
          
          rem %1 = stylesheet
          rem %2 = input xml
          rem %3 = DataPower URL
          
          for /f %%i in ('base64 %1 ^| tr -d "\r\n"') do set b64=%%i
          
          curl -H "xsl: %b64%" --data-binary @%2 %3
          

           

          • KSeeker
            KSeeker
            56 Posts
            ACCEPTED ANSWER

            Re: coproc2

            ‏2014-12-04T20:26:46Z  in response to JimRussell

            Thanks Jim will try the batch.

            Since I already installed CygWin and I am able to run linux commands from any directory on my windows machine e.g., ls pwd etc. I have the 2hex.xsl some.xml files and have also installed MPGW on datapower. I am curious why it doesn't work for this comman?

            $ coproc2 2hex.xsl some.xml http://dp-ip:2223; echo

            'coproc2' is not recognized as an internal or external command....

            • JimRussell
              JimRussell
              39 Posts
              ACCEPTED ANSWER

              Re: coproc2

              ‏2014-12-04T20:34:54Z  in response to KSeeker

              It's been a long time since I used CygWin, so this is just a stab in the dark.  Is the file "coproc2" set as executable?  Can you do a "chmod +x coproc2" and then run it?  Alternately, does it work in a subshell?  (I.E.  "sh coproc2 xyzzy.xsl plugh.xml http://plover:2223")

               

            • kenhygh
              kenhygh
              1427 Posts
              ACCEPTED ANSWER

              Re: coproc2

              ‏2014-12-04T20:39:06Z  in response to KSeeker

              try ./coproc2 2hex.xsl some.xml http://dp-ip:2223; echo

               

              • KSeeker
                KSeeker
                56 Posts
                ACCEPTED ANSWER

                Re: coproc2

                ‏2014-12-04T20:58:28Z  in response to kenhygh

                I had been running it from windows cmd prompt and in my test folder. It seem to work if I run coproc2 from the CygWin command prompt (that's after I copied the coproc2 to the CygWin/bin directory). 

                • HermannSW
                  HermannSW
                  4359 Posts
                  ACCEPTED ANSWER

                  Re: coproc2

                  ‏2014-12-05T10:14:15Z  in response to KSeeker

                  Hi,

                  please look into "coproc2", its a bash shell script:

                  $ cat coproc2
                  #!/bin/bash
                  curl $4 $5 $6 $7 $8 $9 -H "xsl: `gzip -c $1 | base64 | sed -e :a -e '/.*[^\.]$/N;s/\n//;ba'`" --data-binary @$2 $3 
                  $
                  


                  This runs under Linux and Cygwin under Windows.

                  If you want to run coproc2 client under Windows, please compile the coproc2.java client and use that.
                  It should run on any OS (and does not need curl).


                  Hermann.

                  • KSeeker
                    KSeeker
                    56 Posts
                    ACCEPTED ANSWER

                    Re: coproc2

                    ‏2014-12-05T16:51:26Z  in response to HermannSW

                    Hermann - the shell script is working, it wasn't working due to a junk character at the end of xsl stylesheet. 

                    Java Client - I downloaded jdk 7, removed the static from.java class as you suggested in one of your post, and able to compile the coproc2.java however when I run (java coproc2 2hex.xsl some.xml http://dp-ip:2223) I get this error: Error: could not find or load main class coproc2

                    I am running java command in the windows command prompt. 

                    Updated on 2014-12-05T16:53:09Z at 2014-12-05T16:53:09Z by KSeeker
                    • HermannSW
                      HermannSW
                      4359 Posts
                      ACCEPTED ANSWER

                      Re: coproc2

                      ‏2014-12-05T16:58:24Z  in response to KSeeker

                      You will have to add the directory with the compiled .class file to your CLASSPATH environment variable.

                      $ echo $CLASSPATH
                      /home/stammw/bin
                      $ 
                      $ ll ~/bin/coproc2.*
                      -rw-rw-r--. 1 stammw stammw 4920 Oct 22  2013 /home/stammw/bin/coproc2.class
                      -rw-rw-r--. 1 stammw stammw 7142 Oct 22  2013 /home/stammw/bin/coproc2.java
                      $
                      $ java coproc2 2hex.xsl some.xml http://dp2-l3:2223 ; echo
                      74657374
                      $
                      

                       

                      Java client has a "-v" flag returning all response header information in a XML comment, or HTTP response code if that is 400:

                      $ java coproc2 2hex.xsl some.xml http://dp2-l3:2223 -v
                      74657374<!--
                      HTTP/1.1 200 Good
                      xsl: H4sIAAAAAAAAAFWQzW6DMBCE7zyF5UsSKcZFjZBAwBP01h56de2lIPlP3iWQt69Jq7Q97s7MfqPtNrQt0s0CTgDErpBwDr7nVfnEWcHY5qzHNrt6PhHFVsp1Xcv1uQzpU1ZN08j31xf5lpTHMSTHHxET/yWMIhXDCqnUwUnYCPwOwj3wmARYcOBJxATjvAH23EReDEW31wwLxYVYcDOJzBAGtFVJ0b3vDZAzORT53N1M4KJVBMwp0lPPJR+y9CNelV1AhJFhBmraKW1SZt6EDj6/gI55AV4HA8fyfPhQCKK+HE7n+nKu6hOX+61O/uVk8vfi95lD8QUrSYY9XgEAAA==
                      X-Global-Transaction-ID: 939969
                      Host: 127.0.0.1:40000
                      User-Agent: Java/1.7.0
                      X-Client-IP: 127.0.0.1,9.167.244.83
                      Connection: Keep-Alive
                      X-Backside-Transport: OK OK
                      Transfer-Encoding: chunked
                      Date: Fri, 05 Dec 2014 17:00:20 GMT
                      X-Archived-Client-IP: 9.167.244.83,127.0.0.1
                      Via: 1.1 ptlb
                      Content-Type: text/html
                      -->
                      $
                      

                      Hermann.

                      Updated on 2014-12-05T17:08:00Z at 2014-12-05T17:08:00Z by HermannSW
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2011-03-28T18:16:33Z  in response to HermannSW
    "coproc2 again -- integration in Eclipse"
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/coproc2_again_integration_in_eclipse44

    (you can get the screenshots in big by clicking on the small ones)

     
    Hermann<myXsltBlog/>
    • Jaango
      Jaango
      266 Posts
      ACCEPTED ANSWER

      Re: coproc2

      ‏2011-03-29T08:31:56Z  in response to HermannSW
      Hermann,

      Thanks. The features look very useful during the development activities. Just curious, is there a way to see line by line debug option, where we can see the values of the variables, available with this?
      • HermannSW
        HermannSW
        4359 Posts
        ACCEPTED ANSWER

        Re: coproc2

        ‏2011-03-29T17:30:47Z  in response to Jaango
        > Thanks. The features look very useful during the development activities.
        > Just curious, is there a way to see line by line debug option, where we can see the values of the variables, available with this?
        Not with coproc2 as it just sends XSLT+XML to DataPower box and gets response back.

        But perhaps you may be interested in "Stylesheet Tracing" on DataPower?
        http://www-01.ibm.com/support/docview.wss?uid=swg27019118&aid=1#page=6

         
        Hermann<myXsltBlog/>
        • Jaango
          Jaango
          266 Posts
          ACCEPTED ANSWER

          Re: coproc2

          ‏2011-03-31T10:33:12Z  in response to HermannSW
          Hermann,

          Thanks. This is excatly what I was looking for. However I am not sure which page in the webgui to go for getting the http trace output. Can you please help me. I configured a matching rule at the debug level for the xmlmanager.
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2 [v1.2 available]

    ‏2011-05-28T01:04:07Z  in response to HermannSW
    Hello,

    I was asked on the latest status of coproc2.

    coproc2 DataPower service attached to initial posting of this thread
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14590913#14590913
    is still current -- there was no need to change anything since then.

    Early march posting "xs:decimal()"
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/xs_decimal19
    discussed modying the XML manager of DataPower coproc2 service.

    End of march posting "coproc2 again -- integration in Eclipse"
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/coproc2_again_integration_in_eclipse44
    showed how to make use of coproc2.java in Eclipse.

    April 1st posting
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/april_1_2011_5_15_pm14
    screenshot did show output of HTTP response code as well as HTTP response headers.
    I did not post that version of coproc2.java until now.

    After that related posting "webDataPower"
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/webdatapower19
    showed a solution of sending a stylesheet and XML file to DataPower for execution as coproc2 does.
    The difference is that webDataPower does it from within a browser form.

    So today I post new version 1.2 of coproc2.java (attached).
    Find the version feature description in its header:
    
    /** * coproc2 * - send stylesheet and xmlfile to a DataPower appliance; * - display DataPower result of applying stylesheet to xmlfile. * * Modification of SOAPClient4XG from this article: * http://www.ibm.com/developerworks/xml/library/x-soapcl/ * * Added sending of base64(gzip(stylesheet2Send)) as HTTP header. * * 1.1: * Removed "static" from final variables b64[] and pad for JDK 1.4 and 1.5 * * 1.2: * Fixed reading of response in case of HTTP errors, from here: * http://stackoverflow.com/questions/613307/read-error-response-body-in-java/2092749#2092749 * * Allowed '-' as xmlFile2Send to read from standard input. * * Added optional verbose option for output of response HTTP headers. * * if (not verbose) { *   if (HTTP response code >= 400) output it  [error] * } else { *   output HTTP response code *   output HTTP response headers * } * * * @author  Hermann Stamm-Wilbrandt * @version 1.2 * @param   stylesheet2Send  stylesheet to be executed on DataPower * @param   xmlFile2Send     xmlfile sent to DataPower (or '-' for standard input) * @param   url              URL of coproc2 Endpoint on DataPower * @param   [-v]             optional, do verbose output */
    


    All postings tagged with coproc2:
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/tags/coproc2

     
    Hermann<myXsltBlog/>
    • HermannSW
      HermannSW
      4359 Posts
      ACCEPTED ANSWER

      Re: coproc2 [v1.2 available]

      ‏2011-05-28T01:49:26Z  in response to HermannSW

      new features demonstration


      Let me demonstrate the new features by this stylesheet (also attached):
      
      $ cat reject.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" />   <xsl:template match=
      "/"> <dp:set-variable name=
      "'var://service/error-protocol-response'" value=
      "." /> <dp:reject>reject with error-protocol-response</dp:reject> </xsl:template>   </xsl:stylesheet> $
      


      So we will use standard input to provide the XML file to process by selecting '-'.
      The input data will be taken by above stylesheet as HTTP code to return after reject.

      without new verbose mode.


      If HTTP response code is not an error code (<400) then only the normal response is given:
      
      $ echo 
      "<code>200</code>" | \ > java coproc2 reject.xsl - http:
      //dp3-l3:2223  <?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>reject with error-protocol-response (from client)</faultstring></env:Fault></env:Body></env:Envelope> $
      


      If HTTP response code is an error code (>=400) it is appended as XML comment to the normal response (this circumvents the problem of forbidden preceding of xml declaration):
      
      $ echo 
      "<code>418</code>" | \ > java coproc2 reject.xsl - http:
      //dp3-l3:2223  <?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>reject with error-protocol-response (from client)</faultstring></env:Fault></env:Body></env:Envelope> <!-- HTTP response: 418 Error --> $
      


      new verbose mode.


      In verbose mode always the HTTP response code is appended to normal response, together with all HTTP response headers:
      
      $ echo 
      "<code>200</code>" | \ > java coproc2 reject.xsl - http:
      //dp3-l3:2223 -v <?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>reject with error-protocol-response (from client)</faultstring></env:Fault></env:Body></env:Envelope> <!-- HTTP/1.1 200 Error Content-Type: text/xml Connection: close X-Backside-Transport: FAIL FAIL --> $
      


      standard input XML data


      Being able to process XML data from standard input opens up a whole new range of applications.

      See for example posting "Nice combination of xpath++ and doSoma tools for querying AdminState and OpState of MQ FSHs":
      https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/nice_combination_of_xpath_and_dosoma_tools_for_querying_adminstate_and_opstate_of_mq_fshs

      There the output of a XML management call was further processed by xpath++ tool.
      The power of a stylesheet is much bigger than pure XPath statements.
      See the same XML management output nicely formatted by stylesheet ObjectStatus.xsl and executed by coproc2.java:
      
      $ doSoma admin ObjectStatus.xml dp3-l3:5550 | \ > java coproc2 ObjectStatus.xsl - http:
      //dp3-l3:2223 Enter host password 
      
      for user 
      'admin': Name......AdminState..OpState ----------------------------- MQ_FSH_1..disabled....down.... MQ_FSW_2..enabled.....down.... $ $ cat ObjectStatus.xsl <xsl:stylesheet version=
      "1.0" xmlns:xsl=
      "http://www.w3.org/1999/XSL/Transform" xmlns:str=
      "http://exslt.org/strings" xmlns:dp=
      "http://www.datapower.com/extensions" extension-element-prefixes=
      "dp" > <xsl:output method=
      "text" /> <xsl:template match=
      "text()"/>   <xsl:template match=
      "*"> <xsl:value-of select=
      "str:align(Name, '..........', 'left')" /> <xsl:value-of select=
      "str:align(AdminState, '............', 'left')" /> <xsl:value-of select=
      "str:align(OpState, '........', 'left')" /> <xsl:text>
      </xsl:text> </xsl:template> <xsl:template match=
      "/"> <xsl:text>Name......AdminState..OpState&​#10;</xsl:text> <xsl:text>-----------------------------&​#10;</xsl:text> <xsl:apply-templates select=
      "//ObjectStatus[Class='MQSourceProtocolHandler']"/> </xsl:template> </xsl:stylesheet> $
      


      Hermann<myXsltBlog/>

      Attachments

  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2 / coproc2nonxml

    ‏2011-10-04T13:17:39Z  in response to HermannSW
    The coproc2 client ("coproc2" bash script as well as "coproc2.java") is able to send Non-XML data,
    but the coproc2 service attached at top of this thread is not able to deal with that.

    Find service coproc2nonxml attached to this posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14676613#14675883

    The only changes to coproc2 service are:
    • Non-XML request type
    • "Transform Binary" action instead of "Transform" action
    • listening on port 2224 instead of port 2223
    (input INPUT, output OUTPUT and transform in context "xsl" as before)

    It allows to process Non-XML data in binary-transform stylesheets.
    And even more, it allows for chaining Non-XML and XML transformations by pipelining coproc2 calls against the different endpoints!
    See the sample discussed in the posting.

    $ coproc2 ampify.xsl 412.html http://dp3-l3:2224 | coproc2 body2Extract.xsl - http://dp3-l3:2223
    


     
    Hermann <myXsltBlog/>
    Updated on 2014-03-25T03:09:35Z at 2014-03-25T03:09:35Z by iron-man
    • Jaango
      Jaango
      266 Posts
      ACCEPTED ANSWER

      Re: coproc2 / coproc2nonxml

      ‏2011-10-10T07:59:56Z  in response to HermannSW
      Hi,
      Is there a way to get the size of the input, in non xml format, using xsl?In WTX we have the SIZE() function. For example in the attached file, 41, the size of file is 1 byte/character.

      Attachments

      • HermannSW
        HermannSW
        4359 Posts
        ACCEPTED ANSWER

        Re: coproc2 / coproc2nonxml

        ‏2011-10-10T16:37:51Z  in response to Jaango
        Hi Maneesh,
        >
        > Is there a way to get the size of the input, in non xml format, using xsl?
        > In WTX we have the SIZE() function. For example in the attached file, 41, the size of file is 1 byte/character.
        >
        OK, so your input is zip-archive 41.zip.
        And you want the size of file "41" in that archive (which is 1):
        
        $ unzip -l 41.zip Archive:  41.zip Length     Date   Time    Name --------    ----   ----    ---- 1  01-18-11 13:17   41 --------                   ------- 1                   1 file $ ls -l 41.zip -rw-rw-r-- 1 stammw stammw 103 Oct 10 17:59 41.zip $
        


        I will give the 2nd WSTE webcast on "Non-XML data processing in DataPower stylesheets" this Thursday.
        The presentation is already online, slide 19 shows "makeSwa" solution I used to create unzip-l.xsl from it:
        http://www-01.ibm.com/support/docview.wss?uid=swg27022979&aid=1#page=19
        Stylesheet unzip-l.xsl does the same as "unzip -l" command (giving you access to all information):
        
        $ coproc2 unzip-l.xsl 41.zip http:
        //dp3-l3:2224 -s | tidy -q -xml <attachment> <uri>cid:myZip</uri> <size>103</size> <header> <name>Content-ID</name> <value><myZip></value> </header> <header> <name>Content-Transfer-Encoding</name> <value>binary</value> </header> <header> <name>Content-Type</name> <value>application/zip</value> </header> <files> <file> <filename>41</filename> <size>1</size> </file> </files> </attachment>   $
        

        Stylesheet unzip-l.xsl (also attached):
        
        <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" > <dp:input-mapping href=
        "store:///pkcs7-convert-input.ffd" type=
        "ffd"/>   <xsl:output omit-xml-declaration=
        "yes"/>   <xsl:template match=
        "/"> <!-- a SOAP message --> <xsl:variable name=
        "dummy"> <env:Envelope xmlns:env=
        "http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <dummySOAPnode/> </env:Body> </env:Envelope> </xsl:variable>     <!-- create context 
        "swa" with that SOAP message --> <dp:set-variable name=
        "'var://context/swa'" value=
        "$dummy" />   <!-- set Content-Type --> <dp:set-http-request-header name=
        "'Content-Type'" value=
        "'application/soap+xml'" />   <!-- attach zip-archive to context 
        "swa" (
        "myZip" Content-ID) --> <dp:url-open target=
        "attachment://swa/cid:myZip" data-type=
        "base64" response=
        "ignore" content-type=
        "application/zip" > <xsl:value-of select=
        "dp:binary-encode(/object/message/node())" /> </dp:url-open>     <!-- output context swa
        's attachment manifest (only) attachment --> <xsl:copy-of select=
        "dp:variable('var://context/swa/attachment-manifest')/ manifest/attachments/attachment
        "/> </xsl:template>   </xsl:stylesheet>
        


        And this is the output of applying unzip-l.zip to a zip-archive containing more files and directory structure!
        
        $ coproc2 unzip-l.xsl coproc2.zip http:
        //dp3-l3:2224 -s | tidy -q -xml <attachment> <uri>cid:myZip</uri> <size>409705</size> <header> <name>Content-ID</name> <value><myZip></value> </header> <header> <name>Content-Transfer-Encoding</name> <value>binary</value> </header> <header> <name>Content-Type</name> <value>application/zip</value> </header> <files> <file> <filename>export.xml</filename> <size>11288</size> </file> <file> <filename>local/</filename> <size>0</size> </file> <file> <filename>local/coproc2.xsl</filename> <size>642</size> </file> <file> <filename>dp-aux/</filename> <size>0</size> </file> <file> <filename>dp-aux/clixform.xsl</filename> <size>200647</size> </file> <file> <filename>dp-aux/SchemaUtil.xsl</filename> <size>20520</size> </file> <file> <filename>dp-aux/management.xsl</filename> <size>7101</size> </file> <file> <filename>dp-aux/map-dmz.xsl</filename> <size>5684</size> </file> <file> <filename>dp-aux/drMgmt.xml</filename> <size>2997463</size> </file> <file> <filename>dp-aux/basetypes.xml</filename> <size>6819</size> </file> </files> </attachment>   $
        


         
        Hermann<myXsltBlog/>
        • Jaango
          Jaango
          266 Posts
          ACCEPTED ANSWER

          Re: coproc2 / coproc2nonxml

          ‏2011-10-11T09:14:29Z  in response to HermannSW
          Hermann,

          Thanks. Can we also count the number of characters(in the attached text file, it is 412 characters/bytes) for text files, using a non xml, xsl transformation?
          • HermannSW
            HermannSW
            4359 Posts
            ACCEPTED ANSWER

            Re: coproc2 / coproc2nonxml

            ‏2011-10-11T10:10:10Z  in response to Jaango
            Hi Maneesh,
            >
            > Thanks. Can we also count the number of characters(in the attached text file, it is 412 characters/bytes) for text files, using a non xml, xsl transformation?
            >
            Yes.

            Depending on the frontside handler you may get the request size from 'var://service/mpgw/request-size' (eg. for HTTP).

            So there is an easy solution, and a nice solution when the variable does not get populated (will be 0 for eg. MQ FSH).

            First the easy solution (read request-size variable):
            
            $ ls -l filename.txt -rw-rw-r-- 1 stammw stammw 412 Oct 11 11:51 filename.txt $ $ coproc2 request-size.xsl filename.txt http:
            //dp3-l3:2224; echo 412 $ $ cat request-size.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" > <dp:input-mapping  href=
            "store:///pkcs7-convert-input.ffd" type=
            "ffd"/>   <xsl:output omit-xml-declaration=
            "yes" /> <xsl:template match=
            "/"> <xsl:value-of select=
            "dp:variable('var://service/mpgw/request-size')"/> </xsl:template> </xsl:stylesheet> $
            

            And here the nice solution making used of func:base64-length():
            
            $ coproc2 req-size.xsl filename.txt http:
            //dp3-l3:2224; echo 412 $ $ cat req-size.xsl <xsl:stylesheet version=
            "1.0" xmlns:xsl=
            "http://www.w3.org/1999/XSL/Transform" xmlns:func=
            "http://exslt.org/functions" xmlns:dp=
            "http://www.datapower.com/extensions" extension-element-prefixes=
            "dp" > <dp:input-mapping  href=
            "store:///pkcs7-convert-input.ffd" type=
            "ffd"/>   <xsl:output omit-xml-declaration=
            "yes" /> <xsl:template match=
            "/"> <xsl:copy-of select=
            "func:base64-length(dp:binary-encode(/object/message/node()))"/> </xsl:template> <!-- 
            
            return length of decoded base64 string $bytes (string-length replacement) --> <func:function name=
            "func:base64-length"> <xsl:param name=
            "bytes"/>   <xsl:choose> <xsl:when test=
            "contains($bytes,'==')"> <func:result select=
            "(string-length($bytes) div 4) * 3 - 2"/> </xsl:when> <xsl:when test=
            "contains($bytes,'=')"> <func:result select=
            "(string-length($bytes) div 4) * 3 - 1"/> </xsl:when> <xsl:otherwise> <func:result select=
            "(string-length($bytes) div 4) * 3"/> </xsl:otherwise> </xsl:choose> </func:function>   </xsl:stylesheet>   $
            


             
            Hermann<myXsltBlog/>
            • Jaango
              Jaango
              266 Posts
              ACCEPTED ANSWER

              Re: coproc2 / coproc2nonxml

              ‏2011-10-11T10:57:38Z  in response to HermannSW
              Perfect,

              Thanks Hermann. This is exactly what we needed.
              • Jaango
                Jaango
                266 Posts
                ACCEPTED ANSWER

                Re: coproc2 / coproc2nonxml

                ‏2011-10-11T12:37:58Z  in response to Jaango
                Hi Hermann,

                Just curious, why '==' gets appended at the end of the file, after dp:binary-encode(/object/message/node()), on the input?. Is it something like the end of the file?. When can '=' come?Also is there a chance of getting appended, more '=' at the end?
                • Liv2luv
                  Liv2luv
                  573 Posts
                  ACCEPTED ANSWER

                  Re: coproc2 / coproc2nonxml

                  ‏2011-10-11T15:06:01Z  in response to Jaango
                  Manish, you did not specify the nature of the message being received (XML or non-XML).

                  There may be a variation between bytes and characters count depending on the input data. In WTX, You can count bytes using the SIZE function and count characters using CSIZE function. On XML data, NORMXML function must be used to remove the XML formatting to get correct size.

                  when the text file 412.txt is run through a MQ FSH, it reports both the var://service/input-size and var://service/mpgw/request-size as 565.

                  Input text:

                  
                  ÇÄ×ÇÅã×ÙÖÄÙÅØðñ@ù@@ÅÙÙÖÙ@ÅÕÃÖäÕãÅÙÅÄ@@Çõñó`ÙÅãäÙÕ`ÃÖÄÅ@~@ðñðö@ÔÁãÃÈÉÕÇ@ÇÄâÙ@ÅÕãÙè@ÕÖã@ÆÖäÕÄ@ÆÖÙ@@ÇÄ×ÇÅã×ÙÖÄÙÅØðñ@ðððñ@@@@@@@@@@@@@@@@@@@@@@@×ÓÅÁâÅ@ÃÈÅÃÒ@æÉãÈ@âä××ÖÙã@ÁÕÄ@ÙÅãÙè@@@@@@@@@@@@@ãÈÁÕÒ@èÖä@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Çõñô`ÙÅãäÙÕ`ÃÖÄÅ@~@ðñðö@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                  


                  With in DataPower:
                  
                  ÇÄ×ÇÅã×ÙÖÄÙÅØðñ@ù@@ÅÙÙÖÙ@ÅÕÃÖäÕãÅÙÅÄ@@Çõñó`ÙÅãäÙÕ`ÃÖÄÅ@~@ðñðö@ÔÁãÃÈÉÕÇ@ÇÄâÙ@ÅÕãÙè@ÕÖã@ÆÖäÕÄ@ÆÖÙ@@ÇÄ×ÇÅã×ÙÖÄÙÅØðñ@ðððñ@@@@@@@@@@@@@@@@@@@@@@@×ÓÅÁâÅ@ÃÈÅÃÒ@æÉãÈ@âä××ÖÙã@ÁÕÄ@ÙÅãÙè@@@@@@@@@@@@@ãÈÁÕÒ@èÖä@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Çõñô`ÙÅãäÙÕ`ÃÖÄÅ@~@ðñðö@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                  


                  finally for '==' and '=' padding characters in base-64 encoded text please read through http://en.wikipedia.org/wiki/Base64#Padding

                  Thanks.
            • Liv2luv
              Liv2luv
              573 Posts
              ACCEPTED ANSWER

              Re: coproc2 / coproc2nonxml

              ‏2011-10-11T14:51:24Z  in response to HermannSW
              Sorry, but I have made a quick test and see the variables var://service/input-size and var://service/mpgw/request-size are being populated with the value when a text message is processed by a MQFSH.

              I do remember reading a technote about these variables getting populated from firmware 3.8.x when the input is non-XML.

              However this value may be inconsistent depending on the data input.

              Thanks.
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2 / piggyback.xsl

    ‏2011-10-18T19:08:56Z  in response to HermannSW
    I want to post a new technique for coproc2 service, demonstrated by (attached) stylesheet piggyback.xsl.

    The piggyback technique is making use of coproc2 service "inside" a stylesheet being executed by coproc2 service itself.

    piggyback.xsl contains the stylesheet of xpath++ service from this posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14511881#14511881

    It just takes the input, prepares everything for calling coproc2 with its piggyback stylesheet, and then just returns the result.

    So this is how xpath++ tool is used:
    
    $ xpath++ usage: xpath++ <XPath expression> <XML file> $
    


    In addition to the piggyback (xpath++) stylesheet we have to pass the <XML file> and the <XPath expression> in our coproc2 call.
    We do so by having the <XPath expression> in the query part of coproc2 endpoint:
    
    $ coproc2 piggyback.xsl ab.xml 
    "http://dp0-l3:2223?count(//*)"; echo 2 $ $ cat ab.xml <a>1<b>2</b>3</a> $
    


    Btw, the xpath++ stylesheet is a dual use stylesheet for DataPower as well as xsltproc XSLT processor.
    Because of this dual use we have to provide the <XPath expression> for (DataPower) use of the stylesheet in a HTTP header variable.
    Looking in what eg. the coproc2 shell script client does
    
    #!/bin/bash curl $4 -H 
    "xsl: `gzip -c $1 | base64 | sed -e :a -e '/.*[^\.]$/N;s/\n//;ba'`" --data-binary @$2 $3
    

    we see that the "base64 encoded gzipped stylesheet" gets passed in HTTP header "xsl" to the coproc2 endpoint.

    Therefore we provide the xpath++ stylesheet in <xsl:variable name="delim.xml.gz.b64">.

    We have to return the result of xpath++ stylesheet execution as Non-XML because the stylesheets returns text consisting of XML Characters only.
    That is the reason for use of <dp:output-mapping ...>.

    See the datails of piggyback.xsl in the code listing (also attached):
    
    <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" > <dp:output-mapping href=
    "store:///pkcs7-convert-input.ffd" type=
    "ffd"/>   <xsl:template match=
    "/">   <!-- curl -u 
    "$1:" ... ==> $authString --> <xsl:variable name=
    "query" select=
    "substring-after(dp:variable('var://service/URI'),'?')"/>   <xsl:variable name=
    "authString" select=
    "concat('Basic ', dp:encode(concat($query,
    ':'),
    'base-64'))
    "/>     <xsl:variable name=
    "httpHeaders"> <!-- base64 encoded, gzipped piggyback service into 
    "xsl" header--> <header name=
    "xsl"> <xsl:value-of select=
    "normalize-space($delim.xml.gz.b64)"/> </header>   <!-- setup 
    "Authorization" header 
    
    for delim.xml stylesheet --> <header name=
    "Authorization"> <xsl:value-of select=
    "$authString"/> </header> </xsl:variable>     <!-- determine coproc2 service --> <xsl:variable name=
    "coproc2service" select=
    "dp:variable('var://service/local-service-address')"/>   <!-- go against coproc service on same device --> <xsl:variable name=
    "coproc2" select=
    "concat('http://',$coproc2service)"/>     <!-- pass XPath in 
    "Authorization" header and input XML as payload --> <xsl:variable name=
    "response"> <dp:url-open target=
    "{$coproc2}" response=
    "binaryNode" data-type=
    "xml" http-headers=
    "$httpHeaders" > <xsl:copy-of select=
    "/"/> </dp:url-open> </xsl:variable>     <!-- 
    
    return result from delim.xml stylesheet (xpath++ service) --> <object> <message> <xsl:copy-of select=
    "$response/result/binary/node()"/> </message> </object> </xsl:template>     <xsl:variable name=
    "delim.xml.gz.b64"> H4sICIg9nE4AA2RlbGltLnhtbACtVk2P0zAQvfdXmGiltmjdbAEhbbRdCc6LOCyHvSE3mTRGiR1s Z9sgfjzjfDRO6rAI2NN28ubN85sZJ3evKE0g5wWl94u7k84jbeocdAZgyDMozaXYBdvNTbAg5FTk QkcI2gWZMWUUhsfjcXN8u5HqEG5vb2/Dp8eH8ItiQqdSFQFxcnwpb25utuHTp4fHOIOCDRUSZuCM B6xnGrgNa8pEQg0vQDv4WvjgtWAFjwcYuMoHXCyLQooBllYi9sBs2KAbTt2CmcyDtOEBhG4ksvDA 2gcOEA5wKn1AOFQ5UxSfKtB6rEGD8aRg1MUY5cMYxcXBtbEcNQntZqU8gtqgQ5hnQJxrn39RyKEA YShKS/kJsM9JSdD6YHGPuGaiZGXKypACTCaTXYDFAiILbij+h8MX49mYaeasxq6GmNdnlvikINhG HIdTibZiICAuwkBR5jgXBE2PsRlhYMt2D5+Z4myfg8vQPe8QcSalhj7UBY8ZCIKjhsb2TafsmfHc cq2WSRlZl6iC7xWCaAYsAbVcBwONvz6rsDxxQIRotC821jMf52r5AVOk4j8af7BE+FKN/ft3MyV0 tW87TllqkPvKyrlefmSax+RPqCsN6uu8/j0XTNW2nzKB1RUK8XPmFVCZ/l7i6qopdr297iTnIA4m 68Jruh1R34V91yaNlCYDdeRugycyzqWvzuN1QXzB0obd0WkjvV/tePpNxAWuchMMxtUiAqsGZ3jV imjONhCMR3Q6oNAo3H9DMmrqEjnaCuvdUmAfKF4Ey2BiC97NFFicDYfvVF3YFLM8p+cVa0+QyM/N Pl8a1fOOfXL7MteVmZ50ssIx4SR/2o32dy8anby4KibncC4Mg/fa/YL+379Fr8hyv9jWsydtf9GL NIrsKwov2dWa/BzvX7M7CCiVjO2rAVeFC9yZqrm15vFWzGo9HYxYlrXbgM3U+ote+iTHskKpGyy9 2YTM4ALvKwNR9LqNWPd1yWIbWZNXu4m+LvvFzH/XPjeHPPUdZCx7N+icU+WOVPN+nY6Br6Qls32J WjBPpzs2ini3pqMIJ7im7i7wifDzdDfxDJOH6K+2k3TbMXx14meo+036C5hBb+2hCgAA </xsl:variable>   </xsl:stylesheet>
    


     
    Hermann<myXsltBlog/>
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2011-10-18T19:30:39Z  in response to HermannSW
    Although xpath++ tool is a nice demonstration for piggyback technique of coproc2,
    a "normal" stylesheet solution for xpath++ tool using coproc2 is preferable.

    Find that xpath++.xsl stylesheet in this posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14694527#14694527

    Just another sample:
    $ echo "<b>3<a>2</a>1</b>" | java coproc2 xpath++.xsl - "http://dp2-l3:2223?//node()"
     
    -------------------------------------------------------------------------------
    <b>3<a>2</a>1</b>
    -------------------------------------------------------------------------------
    3
    -------------------------------------------------------------------------------
    <a>2</a>
    -------------------------------------------------------------------------------
    2
    -------------------------------------------------------------------------------
    1
    $
    


    There are other uses of piggyback technique for coproc2 making more sense.

     
    Hermann <myXsltBlog/>
    Updated on 2014-03-25T03:08:11Z at 2014-03-25T03:08:11Z by iron-man
    • HermannSW
      HermannSW
      4359 Posts
      ACCEPTED ANSWER

      Re: coproc2

      ‏2011-10-18T20:13:29Z  in response to HermannSW
      Now just one last demonstration of interweaving all what we have seen sofar :-)

      This is just how to decode the piggyback stylesheet of piggyback.xsl with DataPower extension functions:
      
      $ java coproc2 xpath++.xsl piggyback.xsl 
      "http://dp3-l3:2223?"\ > 
      "dp:parse(dp:inflate(normalize-space(//xsl:variable[@name='delim.xml.gz.b64']/text()),'gzip'))"   ------------------------------------------------------------------------------- <!--delim--><xsl:stylesheet version=
      "1.0" extension-element-prefixes=
      "dp dyn" xmlns:xsl=
      "http://www.w3.org/1999/XSL/Transform" xmlns:xs=
      "http://www.w3.org/2001/XMLSchema" xmlns:date=
      "http://exslt.org/dates-and-times" xmlns:dyn=
      "http://exslt.org/dynamic" xmlns:exsl=
      "http://exslt.org/common" xmlns:func=
      "http://exslt.org/functions" xmlns:math=
      "http://exslt.org/math" xmlns:random=
      "http://exslt.org/random" xmlns:regexp=
      "http://exslt.org/regular-expressions" xmlns:set=
      "http://exslt.org/sets" xmlns:str=
      "http://exslt.org/strings" xmlns:dp=
      "http://www.datapower.com/extensions"> <xsl:output method=
      "xml" omit-xml-declaration=
      "yes"/> <xsl:param name=
      "xpathpar"/> <xsl:template match=
      "/"> <xsl:variable name=
      "xpath"> <xsl:choose> <xsl:when test=
      "function-available('dp:http-request-header')"> <xsl:variable name=
      "auth" select=
      "dp:http-request-header('Authorization')"/> <xsl:variable name=
      "b64" select=
      "substring-after($auth,'Basic ')"/> <xsl:variable name=
      "user_" select=
      "dp:binary-decode($b64)"/> <xsl:value-of select=
      "substring($user_,1,string-length($user_)-1)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select=
      "$xpathpar"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name=
      "result" select=
      "dyn:evaluate($xpath)"/>   <xsl:choose> <xsl:when test=
      "exsl:object-type($result)='node-set'"> <xsl:for-each select=
      "$result"> <xsl:call-template name=
      "doOutput"/> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:value-of select=
      "$result"/> </xsl:otherwise> </xsl:choose> </xsl:template>     <xsl:template name=
      "doOutput"> <xsl:text> ------------------------------------------------------------------------------- </xsl:text> <xsl:choose> <xsl:when test=
      "self::comment() |                self::processing-instruction() |                self::text()"> <xsl:copy-of select=
      "."/> </xsl:when> <xsl:when test=
      "count(. | ../attribute::* | ../namespace::*) !=               count(../attribute::* | ../namespace::*)"> <xsl:copy-of select=
      "."/> </xsl:when> <xsl:otherwise> <xsl:
      
      if test=
      "count(. | ../namespace::*) = count(../namespace::*)"> <xsl:text>xmlns</xsl:text> <xsl:
      
      if test=
      "name()">:</xsl:if> </xsl:if> <xsl:value-of select=
      "name()"/> <xsl:text>=
      "</xsl:text> <xsl:value-of select=
      "string()"/> <xsl:text>
      "</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet><!--delim--> $
      


      Hermann<myXsltBlog/>
      • Jaango
        Jaango
        266 Posts
        ACCEPTED ANSWER

        Re: coproc2

        ‏2011-12-07T07:11:14Z  in response to HermannSW
        Hi Hermann,

        We have a need to capture whole response(Actually it is in EBCdic format) coming from a backend, during a particular error, save in .txt format, under local:/// folder.

        The whole background is ,

        Our binary transform in the response rule fails with the dp service variable error message "Inputs Not Valid"(example only), then goes to error rule. We wanted to know the exact response payload coming from backend for troubleshooting. This response message(specific to the error) is coming very rarely, making it difficult to trouble shoot.

        So in the error rule, using the first transform, we would like to set a .txt file, under local/// folder, which will have the corresponding response payload for further analysis. The payload looks similar to the filename.txt, in my earlier post.
        Could you please provide some guidance on how this can be achieved.
        • HermannSW
          HermannSW
          4359 Posts
          ACCEPTED ANSWER

          Re: coproc2

          ‏2011-12-08T00:59:56Z  in response to Jaango
          > Hi Hermann,
          >
          > We have a need to capture whole response(Actually it is in EBCdic format) coming from a backend, during a particular error, save in .txt format, under local:/// folder.
          >
          Storing under local:/// is only possible via the XML Management interface.
          I doubt that you want the overhead of "Accessing XML Management interface from within a stylesheet":
          https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/accessing_xml_management_interface_from_within_a_stylesheet38

          If I understand you correctly, then what you want is <dp:dump-nodes ...>.

          Your question is not a coproc2 one, but since it is in this thread now, see this coproc2 demonstration of <dp:dump-nodes ...>:
          
          $ cat ab.xml <a>1<b>2</b>3</a> $ $ cat some.xml <some/> $ $ coproc2 dump-nodes.xsl ab.xml http:
          //dp3-l3:2223; echo <a>1<b>2</b>3</a> $ $ coproc2 dump-nodes.xsl some.xml http:
          //dp3-l3:2223; echo <some/> $ $ cat dump-nodes.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" /> <xsl:template match=
          "/"> <dp:dump-nodes file=
          "'abc.xml'" nodes=
          "."/>   <dp:url-open target=
          "temporary:///abc.xml"/> </xsl:template> </xsl:stylesheet> $
          

          Hermann<myXsltBlog/>
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2012-03-20T13:55:07Z  in response to HermannSW
    Today I posted on xml-stylesheet processing instruction and coproc0 service related to coproc2,
    perhaps this might be interesting to you:
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/coproc0_service10

    Especially section "3e) security considerations" applies to coproc2 service as well.

     
    Hermann<myXsltBlog/>
    • cltnc28269
      cltnc28269
      4 Posts
      ACCEPTED ANSWER

      Re: coproc2

      ‏2012-05-17T18:20:05Z  in response to HermannSW
      Hermann,

      You have my respect with regards to immense datapower knowledge you have and more importantly for sharing it online.

      Quick Quesiton -
      How/Can I test an xsl that imports another xsl with coproc2?

      <xsl:import href="util-templates.xsl"/>

      Basically, I have a bunch of XSLTs in my eclipse project that I would like to make changes and test "seamlessly" without having to upload them to Datapower.

      Thank you,
      RK
      • HermannSW
        HermannSW
        4359 Posts
        ACCEPTED ANSWER

        Re: coproc2

        ‏2012-05-18T00:36:56Z  in response to cltnc28269
        Hi,
        > ...
        > Quick Quesiton -
        > How/Can I test an xsl that imports another xsl with coproc2?
        >
        > <xsl:import href="util-templates.xsl"/>
        >
        quick question, not so quick answer, see below.

        > Basically, I have a bunch of XSLTs in my eclipse project that I would like to make changes and test
        > "seamlessly" without having to upload them to Datapower.
        >
        In the past I solved the problem by copying the included files onto the box (to eg. local:) and modify the href.

        A better alternative is (for developent) exposing your files by an HTTP service on your machine in order that DataPower box can access them.
        Now how would you use coproc2 then?
        Let's assume that your top level stylesheet can be accessed by "http://a.b.c.d/path/top.xsl" from DataPower, and your input file is input.xml.
        Create a new stylesheet boot.xsl you can use with coproc2, that references your top level stylesheet!
        
        <xsl:stylesheet version=
        "1.0" xmlns:xsl=
        "http://www.w3.org/1999/XSL/Transform" > <xsl:
        
        import href=
        "http://a.b.c.d/path/top.xsl"/>   </xsl:stylesheet>
        


        Now invoke coproc2.java client (I assume this because you mentioned Eclipse) by
        
        java coproc2 boot.xsl input.xml coproc2endpoint
        


        Normally I prefer to use "store:///pkcs7-convert-input.ffd" for Non-XML processing in a stylesheet
        for exactly the reason you state -- including/importing.

        I did not want to propose above solution without testing.
        So I took a binary transform stylesheet *toBase64f.xsl" referencing an external "base64Binary.ffd".

        These are my files for the test:
        
        $ cat boot.xsl <xsl:stylesheet version=
        "1.0" xmlns:xsl=
        "http://www.w3.org/1999/XSL/Transform" > <xsl:
        
        import href=
        "http://9.164.143.199/toBase64f.xsl"/>   </xsl:stylesheet> $ $ cat /var/www/html/toBase64f.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=
        "base64Binary.ffd" type=
        "ffd"/>   <xsl:template match=
        "/"> <xsl:copy-of select=
        "/Conversion/base64str/text()"/> </xsl:template> </xsl:stylesheet> $ $ cat /var/www/html/base64Binary.ffd <?xml version=
        "1.0" encoding=
        "UTF-8" ?> <File version=
        "2.1" name=
        "Conversion"> <Field name=
        "base64str" type=
        "base64Binary" /> </File> $
        


        After opening my Thinkpad port 80 for allowing external access to my webserver this immediately worked!!
        
        $ od -tcx1 te0t 0000000   t   e  \0   t 74  65  00  74 0000004 $ $ java coproc2 boot.xsl te0t http:
        //dp3-l3:2224 dGUAdA== $ $ java coproc2 boot.xsl te0t http:
        //dp3-l3:2224 | base64 -d | od -tcx1 0000000   t   e  \0   t 74  65  00  74 0000004 $
        

        Thank you so much for the question you raised -- it made me think of this simple solution.

        And you can of course enhance this by a modified coproc2 service on the box to a remote Schema or WSDL validation service.
        Before your question I thought on a coproc3 solution:
        • coproc3 client zips all files needed together
        • sends that .zip to DataPower
        • coproc3 service attaches received .zip to a dummy context
        • then executes the top level stylesheet directly from the attached .zip!

        This technique corresponds to the technique I used to execute stylesheet "dp-aux/clixform.xsl" from a DataPower backup sent against zip2html service.
        Please see "Technical Discussion" if you are interested:
        https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/zip2html6#technical

        But because of your question and above "boot.xsl" answer no coproc3 is needed, at least for me :-)

         
        Last comment on remote testing:
        Please have a look in new Interop services in 5.0.0.x firmware (GA end of June).
        Those allow to do what you want -- for firmware versions below 5.0.0.x coproc2 with boot.xsl is fine.

         
        Hermann<myXsltBlog/> <myXsltTweets/>
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2012-05-18T08:17:29Z  in response to HermannSW
    Hi,

    just did a reality check, changed the dp:input-mapping type from "base64Binary" to "hexBinary" and back.

    Everything works fine
    • my Thinkpad HTTP server flags "base64Binary.ffd" as changed
    • coproc2 service fetches modified file (via boot.xsl -> toBase64f.xsl -> base64Binary.ffd)
    • compiles if needed (yes for hexBinary, no for back to base64Binary because that is already in Stylesheet cache)

    $ java coproc2 boot.xsl te0t http://dp3-l3:2224 
    dGUAdA==
    $ vi /var/www/html/base64Binary.ffd 
    $ java coproc2 boot.xsl te0t http://dp3-l3:2224 
    74650074
    $ vi /var/www/html/base64Binary.ffd 
    $ java coproc2 boot.xsl te0t http://dp3-l3:2224 
    dGUAdA==
    $
    


    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:55:55Z at 2014-03-25T02:55:55Z by iron-man
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2012-09-19T01:53:15Z  in response to HermannSW
    Mr. Craig Oddy updated coproc2.java to v1.3 allowing to upload additional files into "temporary:" folder, nice!
    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=455749

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2 [v1.3 available]

    ‏2013-02-11T14:56:49Z  in response to HermannSW
    Craig made me aware that the last coproc2.java client produces incorrect output if DataPower returned Non-XML data.
    The easiest sample is output of just character 'a' ebcdic-encoded -- the output should be single byte 0x81.

    While the shell script coproc2 client works fine, the Java client returns nonsense:
    
    $ echo 
    "<x>a</x>" | coproc2 to-ebcdic-de.xsl - http:
    //dp3-l3:2223 -s | od -tx1 0000000 81 0000001 $ $ echo 
    "<x>a</x>" | java coproc2 to-ebcdic-de.xsl - http:
    //dp3-l3:2223 | od -tx1 0000000 ef bf bd 0a 0000004 $ $ cat to-ebcdic-de.xsl <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration=
    "yes" encoding=
    "ebcdic-de"/>   <xsl:template match=
    "/"> <xsl:value-of select=
    "."/> </xsl:template> </xsl:stylesheet> $
    


    The reason for wrong output is the history -- first this was on XML in, XML out, later it was on Non-XML in/out in additon.
    But I did not replace the output routine ... :-(

    The fix is just to use the present method "copy()" for returning data to client as well.
    
    $ diff coproc2.old2.java coproc2.java 28a29,30 >  * 1.3: >  * Fixed output of Non-XML DataPower responses 31c33 <  * @version 1.2 --- >  * @version 1.3 171,174c173 <         String inputLine; < <         
    
    while ((inputLine = in.readLine()) != 
    
    null) <             System.out.println(inputLine); --- >         copy(is, System.out); $
    


    You can find new coproc2.java client v1.3 attached.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2013-02-11T15:14:20Z  in response to HermannSW
    Oops -- here is the attachment.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2013-03-21T09:40:27Z  in response to HermannSW
    Find attached the export coproc2resp.zip, which is coproc2 service, where the processing is done on response rule.

    New MPGW copro2resp:
    • listens on port 3222 (instead of 2223 for coproc2)
    • has pass-thru request type
    • goes against http://127.0.0.1:2222 backend
    • had XML response type with slightly modified coproc2.xsl (see below)

    New service coproc2ptlb:
    • listens on port 2222
    • loopback XML FW
    • pass-thru request type
    • "default" policy

    And this is slightly modified stylesheet coproc2.xsl.
    It makes sure that skip-backside is only set for request rule processing:
    
    <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 method=
    "xml" omit-xml-declaration=
    "yes"/> <xsl:template match=
    "/"> <dp:set-variable name=
    "'var://context/xsl'" value=
    "dp:inflate(dp:http-request-header('xsl'),'gzip')"/>   <xsl:
    
    if test=
    "not(dp:responding())"> <dp:set-variable name=
    "'var://service/mpgw/skip-backside'" value=
    "1"/> </xsl:if> <!-- <xsl:message dp:priority=
    "error"> <xsl:copy-of select=
    "dp:inflate(dp:http-request-header('xsl'),'gzip')" /> </xsl:message> --> </xsl:template>   </xsl:stylesheet>
    


     
    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>
    • Kumar_Y
      Kumar_Y
      197 Posts
      ACCEPTED ANSWER

      Re: coproc2

      ‏2013-10-21T19:57:38Z  in response to HermannSW

      Hi Hermann,

      Finally I am able to see your blog for some reason I kept getting developer works site under maintenance. I tried to implement the coproc2 in my dev appliance and I am using cywgin. I have copied coproc2, coproc2.java in bin folder for cygwin. ($ which coproc2 /usr/local/bin/coproc2). <br /> I am getting this error $ java coproc2 <br /> Error: Could not find or load main class coproc2 <br /> Can you please help? 

      • Jaango
        Jaango
        266 Posts
        ACCEPTED ANSWER

        Re: coproc2

        ‏2013-10-22T09:38:59Z  in response to Kumar_Y

        Kumar, Have you checked Interoperability test service? It gives a lot of options

        • Kumar_Y
          Kumar_Y
          197 Posts
          ACCEPTED ANSWER

          Re: coproc2

          ‏2013-10-22T13:42:48Z  in response to Jaango

          Hi Manish,

          Can you please explain what is Interoperability test service?? 

          $ java coproc2 2hex.xsl some.xml https://1.2.3.4:2223

          Error: Could not find or load main class coproc2
           
          • HermannSW
            HermannSW
            4359 Posts
            ACCEPTED ANSWER

            Re: coproc2

            ‏2013-10-22T14:18:05Z  in response to Kumar_Y

            Hi Kumar,

            starting with firmware version 5.0.0 Interoperability test services are available:
            http://pic.dhe.ibm.com/infocenter/wsdatap/v5r0m0/index.jsp?topic=%2Fcom.ibm.dp.xi.doc%2FinteropTest_abstract_tutorial.html

            coproc2 can be used for all firmware versions.

            Did you compile "coproc2.java" with "javac"?

            Is "coproc2.class" on your CLASSPATH?


            Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

            • Kumar_Y
              Kumar_Y
              197 Posts
              ACCEPTED ANSWER

              Re: coproc2

              ‏2013-10-22T14:39:40Z  in response to HermannSW

              Hi Hermann,

              https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014590913 I have downloaded the zipfile, 2hex.xsl, some.xml from here and also coproc2.java. I am still getting the same error and I am not how to check the javac on cygwin.$ cat coproc2

              #!/bin/bash
              curl -H "xsl: `gzip -c $1 | base64 | sed -e :a -e '/.*[^\.]$/N;s/\n//;ba'`" --data-binary @$2 $3
              N;s/\n//;ba'`" --data-binary @$2 $3

               

              $ echo $CLASSPATH
              .;C:\Program Files\Java\jre7\lib\ext\QTJava.zip
               
              C:\Program Files\Java\jre7\bin>java coproc2.java
              Error: Could not find or load main class coproc2.java
              C:\Program Files\Java\jre7\bin>coproc2.java
               
              C:\Program Files\Java\jre7\bin>java coproc2.java
              Error: Could not find or load main class coproc2.java

              I haven't added the any classpath I guess Hermann. Can you please tell what class I need to add in Cygwin and I will make the changes in windows as well as VM linux machine.

               

              • HermannSW
                HermannSW
                4359 Posts
                ACCEPTED ANSWER

                Re: coproc2

                ‏2013-10-22T14:46:19Z  in response to Kumar_Y

                Hi,

                the zip file is DataPower service export -- you need to import that on a DataPower box.

                If you are under cygwin you can just use the "coproc2" shell script (if you have "curl" installed).

                Otherwise you have to compile "coproc2.java" by "javac" from Java SDK:

                $ javac coproc2.java
                $ java coproc2
                Usage:  java coproc2 stylesheet xmlfile http://coproc2endpoint [-v]
                $

                 

                As you can see "java coproc2" is how you can execute the coproc2 client (it executes "coproc2.class").

                "java name.java" does never work.


                Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

                 

                 

                Updated on 2013-10-22T14:47:25Z at 2013-10-22T14:47:25Z by HermannSW
                • Kumar_Y
                  Kumar_Y
                  197 Posts
                  ACCEPTED ANSWER

                  Re: coproc2

                  ‏2013-10-22T14:58:37Z  in response to HermannSW

                  Hi Hermann,

                  Yes I am using Cygwin. I do have curl installed on the Cygwin. Please check the below output

                   
                  $ cat coproc2
                  #!/bin/bash
                  curl -H "xsl: `gzip -c $1 | base64 | sed -e :a -e '/.*[^\.]$/N;s/\n//;ba'`" --data-binary @$2 $3
                  N;s/\n//;ba'`" --data-binary @$2 $3
                   
                  $ which curl
                  /usr/bin/curl

                  $ java coproc2

                  Error: Could not find or load main class coproc2
                   
                  • HermannSW
                    HermannSW
                    4359 Posts
                    ACCEPTED ANSWER

                    Re: coproc2

                    ‏2013-10-22T15:44:57Z  in response to Kumar_Y

                    Hi,

                    with the shell script and curl in place, just do this:

                    $ echo "<x/>" | ./coproc2 double.xsl - http://dp1-l2:2223 ; echo
                    <out><x/><x/></out>
                    $


                    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

                    • Kumar_Y
                      Kumar_Y
                      197 Posts
                      ACCEPTED ANSWER

                      Re: coproc2

                      ‏2013-10-22T17:01:30Z  in response to HermannSW

                      Hi Hermann,

                      I guess you forgot to attached double.xsl ?

                      • HermannSW
                        HermannSW
                        4359 Posts
                        ACCEPTED ANSWER

                        Re: coproc2

                        ‏2013-10-22T17:16:58Z  in response to Kumar_Y

                        You can take any stylesheet you want, but here it is ....

                        Attachments

                        • Kumar_Y
                          Kumar_Y
                          197 Posts
                          ACCEPTED ANSWER

                          Re: coproc2

                          ‏2013-10-22T19:42:20Z  in response to HermannSW

                          Thanks Hermann its working now. Can you please help about the java coproc2 also?

                          $ echo "<x/>" | ./coproc2 double.xsl - http://1.2.3.4:2223; echo
                          <out><x/><x/></out>
                           
                          • HermannSW
                            HermannSW
                            4359 Posts
                            ACCEPTED ANSWER

                            Re: coproc2

                            ‏2013-10-22T19:56:02Z  in response to Kumar_Y

                            Hi,

                            you have to install Java Development Kit and add its bin directory to PATH.

                            Then you can use the Java coproc2 client like this (the 1st command creates coproc2.class, the 2nd executes it):

                            $ javac coproc2.java
                            $ echo "<data>1.2</data>" | java coproc2 double.xsl - http://dp2-l3:2223; echo
                            <out><data>1.2</data><data>1.2</data></out>
                            $

    • Rohit-Goyal
      Rohit-Goyal
      119 Posts
      ACCEPTED ANSWER

      Re: coproc2

      ‏2013-10-26T05:45:42Z  in response to HermannSW

      Hi Herman,

      I am trying to do something like coproc2 to work on a different requirement. I found you have created a special transform action which I am not able to create normally using WebUI under MPG.

      <StylePolicyAction name="coproc2_rule_1_xform_1" xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:dp="http://www.datapower.com/schemas/management">
      <mAdminState>enabled</mAdminState>
      <Type>xform</Type>
      <Input>INPUT</Input>
      <Transform>xsl</Transform>
      <TxMode>dpa</TxMode>
      <Output>OUTPUT</Output>
      <NamedInOutLocationType>default</NamedInOutLocationType>
      <OutputType>default</OutputType>
      <Transactional>off</Transactional>
      <SOAPValidation>body</SOAPValidation>
      <SQLSourceType>static</SQLSourceType>
      <Asynchronous>off</Asynchronous>
      <ResultsMode>first-available</ResultsMode>
      <RetryCount>0</RetryCount>
      <RetryInterval>1000</RetryInterval>
      <MultipleOutputs>off</MultipleOutputs>
      <IteratorType>XPATH</IteratorType>
      <Timeout>0</Timeout>
      </StylePolicyAction>

      Can you share how can I create one such transform action which can allow to execute an XSL set under context variable like you have used context variable "'var://context/xsl"?

      Thanks

      Rohit Goyal

  • lenisha
    lenisha
    23 Posts
    ACCEPTED ANSWER

    Re: coproc2

    ‏2013-11-01T20:00:08Z  in response to HermannSW

    Hi Herman,

    Is Interoperability Test Service on port 9990 good replacement for coproc?

     

    Thank you

  • HermannSW
    HermannSW
    4359 Posts
    ACCEPTED ANSWER

    Re: coproc2 / coproc2gatewayscript

    ‏2014-05-04T13:33:53Z  in response to HermannSW

    Further above in this thread
    https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014590913#f5915ec6-99ff-426d-a3d2-c71d6d96efc9

    I described coproc2all service export containing 4 MPGWs with each having its own XML manager:

    • port 2223: XSLT processing XML
    • port 2224: Transform Binary XSLT processing Non-XML
    • port 2225: XQuery processing XML
    • port 2226: JSONiq processing JSON

     

    Attached service export provides additional endpoint

    • port 2227: Gatewayscript processing


    Gatewayscript is new "Javascript" programming model announced for 7.0.0.0 firmware planned to be available June 13:
    http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=AN&subtype=CA&htmlfid=897/ENUS214-117&appname=USN

    You may find details on new coproc2gatewayscript service, as well as samples in this blog posting:
    https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/coproc2gatewayscript

    In case you are an "early access program" customer for 7.0.0.0 you may start using coproc2gatewayscript service just now ...


    Hermann <myBlog/> <myTweets/> | <GraphvizFiddle/> | <xqib/> | <myCE/> <myFrameless/>

    Attachments

    Updated on 2014-05-06T09:48:57Z at 2014-05-06T09:48:57Z by HermannSW
    • HermannSW
      HermannSW
      4359 Posts
      ACCEPTED ANSWER

      Re: coproc2 / coproc2gatewayscript

      ‏2014-06-25T13:46:25Z  in response to HermannSW

      New coproc2gatewayscript service export (needed after 7.0.0.0 shipped), for details see blog posting coproc2gatewayscript again .

      [Kumar pointed to use on XB62 and that does not have XML FW for backend; replaced it by "echo" HTTP service, service export below is the new one]


       

      $ echo "[]" | coproc2 aes/aes.demo.js - http://dp2-l3:2227 
      
           Password: L0ck it up saf3
          Plaintext: pssst ... đon't tell anyøne!
      Encrypted ...: GQLOWZ33qlMC3N9dKwpGzKgWgOW+sfVKZc+X1TOg6ALNXUy/AqXZcw==
      ... Decrypted: pssst ... đon't tell anyøne!
      
      128-bit: 69 c4 e0 d8 6a 7b 04 30 d8 cd b7 80 70 b4 c5 5a 
      192-bit: dd a9 7c a4 86 4c df e0 6e af 70 a0 ec 0d 71 91 
      256-bit: 8e a2 b7 ca 51 67 45 bf ea fc 49 90 4b 49 60 89 
      
      $
      


      And this is the associated extended latency record:
       

      Wed Jun 25 2014 12:23:57 [0x80e007ad][extlatency][info] mpgw(coproc2gatewayscript): tid(140063)[9.152.201.51]: ExtLatency: TS=0,HR=0,BR=0,PS=0,AXF=39,AGS=40,PC=40,CS=40,HS=40,BS=40, == HR=41,BR=41,PS=41,PC=41,HS=41,BS=41,TC=41, [http://9.152.92.59:2227/]
      



      Hermann <myBlog/> <myTweets/> | <GraphvizFiddle/> | <xqib/> | <myCE/> <myFrameless/>

      Updated on 2014-06-25T16:32:59Z at 2014-06-25T16:32:59Z by HermannSW
      • This reply was deleted by Kumar_Y 2014-06-25T16:45:43Z.
        • HermannSW
          HermannSW
          4359 Posts
          ACCEPTED ANSWER

          Re: coproc2 / coproc2gatewayscript

          ‏2014-06-25T16:03:21Z  in response to Kumar_Y

          Hi,

          I am not sure what you are doing.

          $ coproc2 2hex.xsl some.xml http://1.2.3.4:2223; echo
          curl: (7) couldn't connect to host
          
          $
          

           

          You need to replace "1.2.3.4" with the IP address of your DataPower box with coproc2xslt service on port 2223.

          You can find the service in export (export-coporc2all.zip) attached to this posting above in this thread.


          In case you are interested in GatewayScript endpoint (that is what my last posting was about), that sits on port 2227 ...


          Hermann <myBlog/> <myTweets/> | <GraphvizFiddle/> | <xqib/> | <myCE/> <myFrameless/>

          • Kumar_Y
            Kumar_Y
            197 Posts
            ACCEPTED ANSWER

            Re: coproc2 / coproc2gatewayscript

            ‏2014-06-25T16:32:28Z  in response to HermannSW

            Hi Hermann,

            I am using the original datapower IP only and I am able to see the request in the probe also. The thing is I am getting the same value as the input xml even though I am using xslt to transform it.

            I am trying to test the coproc2 script so that I can always use for testing and developing purpose.

            The problem is I was expecting the hex value <some>test</some>, rather I am getting some.xml file only

            kumar@~/coproc2
            $ ./coproc2 2hex.xsl some.xml http://datapowerhost:2223; echo
            <?xml version="1.0" encoding="UTF-8"?>
            <some>test</some>
             

            Please check the attachments.

            Attachments

            Updated on 2014-06-25T16:39:47Z at 2014-06-25T16:39:47Z by Kumar_Y
            • HermannSW
              HermannSW
              4359 Posts
              ACCEPTED ANSWER

              Re: coproc2 / coproc2gatewayscript

              ‏2014-06-25T16:48:14Z  in response to Kumar_Y

              Hi Kumar,

              please import "export-coproc2all.zip" again, the service shown in screenshot is not coproc2xslt.

              As you can see in this part of your screenshot "Transform=store:///identity-all.xsl".

              After importing coporc2xform service you will see "Transform=xsl" instead.

               

              And here you can see that coporc2xslt does what it should:

              $ echo "<x/>" | coproc2 double.xsl - http://dp2-l3:2223 ; echo
              <out><x/><x/></out>
              $
              

               

              Hermann <myBlog/> <myTweets/> | <GraphvizFiddle/> | <xqib/> | <myCE/> <myFrameless/>

              • Kumar_Y
                Kumar_Y
                197 Posts
                ACCEPTED ANSWER

                Re: coproc2 / coproc2gatewayscript

                ‏2014-06-25T18:48:00Z  in response to HermannSW

                Thanks Hermann. I have just made changes to export.xml file, by changing the different domain name value and you were right about the identity transform.

                 

                 

                Updated on 2014-06-25T18:48:15Z at 2014-06-25T18:48:15Z by Kumar_Y
      • jo2
        jo2
        10 Posts
        ACCEPTED ANSWER

        Re: coproc2 / coproc2gatewayscript

        ‏2014-11-07T17:59:58Z  in response to HermannSW

        Hi Hermann!

        coproc2 is a very nice tool indeed, and now with GatewayScript support it is really exciting.

        I do have some trobule getting it up and running. I have followed the instructions for coproc2 GatewayScript, setting up the special soma user and SSL etc.

        When trying to run e.g. the aes_demo.js, I do get error in system log from the coproc2b.xsl:

        mpgw (coproc2gatewayscript): Error while inflating data

        The xsl header is:

        H4sIAAAAAAAAAJ2TwY6bMBCG75HyDlMugUAMSdtVu9G2Wm331sNKPW5XKwMmWCG2aw8J0aov0aftsTaQwFarqi2+2PDNP+OZH4hjKLTcAZSI6jKOD4cD2ck9TSu2wKNiJJOk3sYm01yhiSkzpMRdNZ3sqYZrZuAKNPtWc838mf24yFDPgvV04pZDFDXmIHUOYEnvc5JtgSPUCgwtXnvrHqooF8gabCFljEEghEAuxQ8EZFUFVBx/CvbqFJFxVTLdhly5MsgNasJEpo8K/bNcdE4fwertRdAHS803XbZRcM664EH5hWi3Th27VoqJnDdwA7I49y8zOiOCGyQbuY+pzkq+Z65tMRc5a0bN6xLZCu4fItiyY7/jbZpCap9fJc2yWAP/4DbJGhYLHsCTY+/5g8X5Gr4PaHJCk5fRLl9/nFvFZRvulmHGcCmIrFHVSA6aI/OnE/jz430VXugorz3e9c26BC8cph4+p+5Oo2mp89hH1G03RJY7BzhqGMiIcu74xHrSUcNMB+ovq1+u3i1S3lb06Ds7dBl7J0Tuje3jbaOocF3y7YGYimfMT6LlRWCfUWHL96v/Flu9+U3Muu5fxcZXfC5mN9PJyMSZFHvbV0iPyIBqTY+AEkrWgEHNxcY6qxYZWl149GkEEM+B1g0BZ955DKk1mBPWDGstwE+trygxJS/QDwL4CL6XeGFKUH5p9Xzbq3AGs6C/b9rZOoDQ6Qdgb+n+7taSvwBnSi8OlwQAAA==

        I am running Java (Oracle) 8 (SDK). Might that be an issue?!

        Cheers

        -jo2

        • HermannSW
          HermannSW
          4359 Posts
          ACCEPTED ANSWER

          Re: coproc2 / coproc2gatewayscript

          ‏2014-11-08T15:52:08Z  in response to jo2

          Hi Jo,

          good that you like coproc2.

          Can you please try this simple sample first in order to verify that your coproc2gatewayscript installation is good?

          $ echo "{}" | coproc2 Hello_world.js - http://dp2-l3:2227 ; echo
          Hello, world!
          $ 
          $ cat Hello_world.js 
          session.output.write("Hello, world!");
          $
          


          Hermann.

          • jo2
            jo2
            10 Posts
            ACCEPTED ANSWER

            Re: coproc2 / coproc2gatewayscript

            ‏2014-11-10T09:37:32Z  in response to HermannSW

            Thank you Hermann, I'm on Windows so created two files for the hello world sample. And now the infate seems to work:


            mpgw (coproc2gatewayscript)
            : coproc2b.xsl: Inflate: 'session.output.write("Hello, world!");'

            But the temp.js is not created in local:///

            mpgw (coproc2gatewayscript): Unable to open the script module file 'local:///temp.js'

            In the system log there are only debug and info messages between the inflate alert and the error messages.

            I have deleted the original temp.js included in your export file. Could that be an issue?

            I get a HTTP 200 Ok response from the XML Management interface:

            mpgw (coproc2gatewayscript): HTTP response code 200 for 'https://127.0.0.1:5550/service/mgmt/current'

            I will review the SSL and soma user settings. coproc2 runs in a dedicated domain called "coproc2"

             

            EDIT: If I manually upload the helloworld.js to local:///temp.js, everything seems to work as expected, I get response to coproc2 client:

            Hello, world!<!--
            X-Frame-Options: sameorigin
            Transfer-Encoding: chunked
            HTTP/1.1 200 OK
            Content-type: text/plain
            Server:
            X-Backside-Transport: OK OK
            Connection: Keep-Alive
            X-Global-Transaction-ID: 307606481
            X-Client-IP: 172.27.10.13
            Date: Mon, 10 Nov 2014 09:40:59 GMT
            Frame-Options: sameorigin
            -->

            Cheers

            -jo

            Updated on 2014-11-10T09:43:29Z at 2014-11-10T09:43:29Z by jo2
            • HermannSW
              HermannSW
              4359 Posts
              ACCEPTED ANSWER

              Re: coproc2 / coproc2gatewayscript

              ‏2014-11-10T09:58:36Z  in response to jo2

              Hi Jo,

              I did the initial blog posting before 7.0.0.0 was shipped, and my colleagues from GatewayScript development closed out "temporary:" folder as writable before GA.

              Please reinstall new service export and follow the steps in this followup blog posting:
              https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/coproc2gatewayscript_again

              The new method has to make use of XML Management interface and that needs additional steps. But overall its the cleaner solution.
               

              Hermann.

              Updated on 2014-11-10T10:00:45Z at 2014-11-10T10:00:45Z by HermannSW
              • jo2
                jo2
                10 Posts
                ACCEPTED ANSWER

                Re: coproc2 / coproc2gatewayscript

                ‏2014-11-10T10:41:52Z  in response to HermannSW

                Hi Hermann!

                 

                Yes I have followed those steps.

                I think I found why I was not able to run your Hello World, the temp.js was written to local:/// in the default domain...!

                I modified coproc2b.xsl

                From:

                        <dpm:request domain="default" xmlns:dpm="http://www.datapower.com/schemas/management">
                To:

                        <dpm:request xmlns:dpm="http://www.datapower.com/schemas/management">
                          <xsl:attribute name="domain"><xsl:value-of select="dp:variable('var://service/domain-name')"/></xsl:attribute>
                 

                Then the hello world JavaScript line is written to temp.js in the curreont domain (coproc2 in my case)

                 

                The AES-demo is still not running, but that's some other issue(s) I can look into :-)

                -jo

                • HermannSW
                  HermannSW
                  4359 Posts
                  ACCEPTED ANSWER

                  Re: coproc2 / coproc2gatewayscript

                  ‏2014-11-10T11:14:50Z  in response to jo2

                  > I think I found why I was not able to run your Hello World,
                  > the temp.js was written to local:/// in the default domain...!
                  >
                  Thanks for identifying AND fixing the issue, I updated the blog posting with a link to your posting:
                  https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/coproc2gatewayscript_again

                   

                  > The AES-demo is still not running, but that's some other issue(s) I can look into :-)
                  >
                  Did you copy the 4 modules to the "local:" folder in your application domain?

                  So I decided to make 4 modules out of them, store under "local:" on DataPower and just  require("aes-ctr")  in order to use it.


                  Hermann.

                  • jo2
                    jo2
                    10 Posts
                    ACCEPTED ANSWER

                    Re: coproc2 / coproc2gatewayscript

                    ‏2014-11-10T12:19:25Z  in response to HermannSW

                    :-)

                    I did save this page with the AES JavaScript from the link you mention here:

                    https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/gatewayscript_modules_aes?lang=en:

                    http://www.movable-type.co.uk/scripts/aes.html

                     

                    But I only get aes.js and aes-ctr.js, not the utf8 and base64. I tried to look here, but no utf8.js or base64.js there eithere.

                    http://www.movable-type.co.uk/scripts/js/crypto/

                    Do I need to handcraft those two files?!

                    -jo

                    • HermannSW
                      HermannSW
                      4359 Posts
                      ACCEPTED ANSWER

                      Re: coproc2 / coproc2gatewayscript

                      ‏2014-11-10T12:42:31Z  in response to jo2

                      Hi Jo,

                      the files on the website did change, now only 2 are needed.
                      I just updated my blog post

                      • with how to retrieve the June 2 version of the 4 files for easy demo
                      • that new (real) work should be based on latest JavaScript version from website


                      Hermann.

                      • jo2
                        jo2
                        10 Posts
                        ACCEPTED ANSWER

                        Re: coproc2 / coproc2gatewayscript

                        ‏2014-11-10T13:32:14Z  in response to HermannSW

                        Cool :-)

                        I just managed to get it working with the 2 (aes.js and aes-ctr.js). I moved the two Utf8 functions from aes-ctr.js to a new Utf8.js and the two Base64 functions to a new Base64.js.

                        Then I followed your Diff result from your blog post - and voila - the aes_demo.js is working :-)

                        One thing I also had to change (probably changed in the new script version) was:

                        if (typeof module!='undefined' && module.exports) var Aes = require('./aes'); // CommonJS (Node.js)

                        to
                        if (typeof module!='undefined' && module.exports) var Aes = require('aes'); // CommonJS (Node.js)

                         

                        Also - I think the inflate error was due to charset issue - I saved the aes_demo.js as UTF-8 encoded (using TextPad in Windows), and then the inflate works well.

                         

                        Thank you for all the quick help on this Hermann, I really appreciate it. This will be very helpful GatewayScript tool for me :-)

                         

    • This reply was deleted by KSeeker 2014-12-04T22:08:18Z. Reason for deletion: The solution is working, it didn't work earlier because of a type.
  • AjeetPhadnis
    AjeetPhadnis
    1 Post
    ACCEPTED ANSWER

    Re: coproc2

    ‏2014-12-19T08:46:57Z  in response to HermannSW

    Hello Hernann,

    First of all I am very thankful to you for Your excellent  articles on Datapower in general. I have downloaded Your coproc2 service. and studying at the moment. However, I am New to the Field of Datapower, though I am a Java certified architect , and certified SAP Process Integration architect.. We have recently added to Our infrastructure the ibm DataPower xb62 Device. I am trying to develop a Interface, where a DP MPGW service will use a FTP Poller to get file  from a Remote FTP server, and this is working. And I want to Write this file under DP's  local Directory.

    After the file is writen to DP-local, I want a FTP Server that is also under the same MPGW service, pickup the file and serve on Client request. This FTP Server is working as well. I just Wonder if you could help me show as to how can I Write file to DP's local subdirectory.

    I appreciate Your help and guidance.

    Best Regards,

    Ajeet Phadnis, Ministry of Finance, Norway