3 Replies Latest reply on Oct 27, 2014 5:13 PM by jorgemoralespou_2

    rtgov ip and switchyard file binding

    amsokol19

      Dear All,

       

      I create simple switchyard project that moves xml file from one folder to another.

       

      Xml file example:

      <?xml version="1.0" encoding="UTF-8"?>

      <Data xmlns="urn:ru.rdif:test1:Data:1.0">

            <Item>

                  <Id>12345</Id>

                  <Value>qwerty</Value>

           </Item>

      </Data>


      I prepare rtgov IP project and define typeProcessors:

      [{

        "name":"test1",

        "version":"1.0.0-SNAPSHOT",

        "typeProcessors":{

             "{urn:ru.rdif:test1:Data:1.0}Data":{

                  "contexts":[{

                       "type":"Conversation",

                       "evaluator":{

                            "type":"xpath",

                            "expression":"/Data/Item/Id"

                       }

                  }],

                  "properties":[{

                       "name":"customer",

                       "evaluator":{

                            "type":"xpath",

                            "expression":"/Data/Item/Value"

                       }

                  },{

                       "name":"item",

                       "evaluator":{

                            "type":"xpath",

                            "expression":"/Data/Item/Id"

                       }

                  },{

                       "name":"contentType",

                       "header":"org.switchyard.contentType",

                       "evaluator":{

                            "type":"mvel",

                            "expression":"toString()"

                       }

                  }]

             }

        }

      }]

       

      When I run project I get the following errors:

      12:32:39,474 SEVERE [org.overlord.rtgov.activity.processor.TypeProcessor] (Camel (camel-5) thread #10 - file:///Users/amsokol/Development/workspace-1/--in) Context expression '/Data/Item/Id' failed to obtain a value from information: java.io.BufferedInputStream@475615f7

      12:32:39,475 SEVERE [org.overlord.rtgov.activity.processor.TypeProcessor] (Camel (camel-5) thread #10 - file:///Users/amsokol/Development/workspace-1/--in) Property expression '/Data/Item/Value' failed to obtain a value from information: java.io.BufferedInputStream@475615f7

      12:32:39,475 SEVERE [org.overlord.rtgov.activity.processor.TypeProcessor] (Camel (camel-5) thread #10 - file:///Users/amsokol/Development/workspace-1/--in) Property expression '/Data/Item/Id' failed to obtain a value from information: java.io.BufferedInputStream@475615f7

       

      Does it mean rtgov is not supporting switchyard file binding?

      or may be I do something wrong?

       

      Thank you for help,

      Alexander

        • 1. Re: rtgov ip and switchyard file binding
          jorgemoralespou_2

          Hi,

          I think that because you are using File based gateways, this are streamed by default, so you need to apply a to string conversion to make t work. For this, you should type your contract for the File Service with String parameter, so it gets converted to string before applying the IP Type processors.

           

          Cheers,

          • 2. Re: rtgov ip and switchyard file binding
            amsokol19

            Hi,

             

            Thank you for idea.

             

            Converting to String using contract has the side effect: message type will be "java.lang.String" instead of my "{urn:ru.rdif:test1:Data:1.0}Data".

            It's not good.


            I'm going to try to create custom message composer class that will convert java.io.BufferedInputStream to String or to POJO.

             

            Thanks,

            Alexander

            • 3. Re: rtgov ip and switchyard file binding
              jorgemoralespou_2

              Hi,

              Just check where is the TypeProcessor happening, if it is after the "declarative" transformation or before. If it is after, you can use a transformation to do the trick. If before, you'll need to use either the MessageComposer or use the implicit conversion that happens in the InboundHandler. So, if you're using JAXB for your custom "{urn:ru.rdif:test1:Data:1.0}Data", it will get converted if you set the contract of the service to the Java type and annotate the JAXB class with @XMLRootElement.

               

              Other options can be to use something similar to what is suggested here: Re: Re: Simple forward from file the queue

               

              Hope it helps.