There is few thing that make my work enjoyable with WSO2 ESB as it provides support for JavaScript Object Notation (JSON) payloads in messages. It is not very new feature and it old feature.

It supports

  • JSON message building
  • Converting a payload between XML and JSON
  • Accessing content on JSON payloads
  • Logging JSON payloads
  • Constructing and transforming JSON payloads
  • Troubleshooting, debugging, and logging

But I will explain some basic feature on this and it is worth to know. It makes your task easy all the time. It is accessing content on JSON payloads

  • Listing
  • Sorting
  • Searching
  • Picking
  • Comparing

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="testadmin2"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <payloadFactory media-type="json">
            <format>
            { "store": {
    "book": [
      { "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      { "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      { "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}
            </format>
            <args>
               <arg evaluator="xml" expression="//store/name"/>
               <arg evaluator="xml" expression="//store/price"/>
               <arg evaluator="json" expression="store.toppings.topping"/>
            </args>
         </payloadFactory>
         <property name="messageType" scope="axis2" value="application/json"/>
         <log>
            <property expression="json-eval($.store.book[*].author)" name="JSON-book"/>


            <property expression="json-eval($.store)" name="JSON-Paydsfadx"/>


            <property expression="json-eval($..author)" name="All-author"/>


            <property expression="json-eval($.store..price)" name="prices"/>


            <property expression="json-eval($..book[2])" name="Second-Book"/>


            <property expression="json-eval($..book[:2])" name="First-Two-Books"/>


            <property expression="json-eval($..book[?(@.isbn)])" name="ISBN-Sort"/>


            <property expression="json-eval($..book[?(@.author=='Evelyn Waugh')].author)"
                      name="Search-Author"/>

          <property expression="json-eval($..book[?(@.price>12)])"
                      name="Book-price"/>


         </log>
         <send>
            <endpoint>
               <http method="POST" uri-template="http://127.0.0.1:8020/2"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>
     

image

0

Add a comment

Total Pageviews
Total Pageviews
2 0 5 7 7 0 6
Categories
Categories
Loading