TIBCO | Working with REST and JSON Plugin

In this post we will check how to handle JSON datatype using TIBCO Designer. TIBCO Designer does not comes with built in JSON Palette in version 5.7.X. We need to install REST Plugin in order to use REST/JSON Palettes. JSON is lightweight datatype used in many systems mainly in web applications. JSON is lightweight as it does not require any XSD. We still can  use XML XSD in TIBCO to convert XML to JSON and vise versa.

Activities :

  • Render JSON - Converts XML data string to JSON String
  • Parse JSON   - Converts JSON String to XML data string 

REST Plugin also have Invoke REST API and REST Dispatch & Reply palette which is better explain in TUTOTIALSPEDIA blog.


Step 1 : Create simple process with HTTP receiver and Send HTTP response activity.



We have simple HTTP Receiver activity to receive XML requests then we will parse received XML string and pass it to Render JSON Palette activity. After XML is converted to JSON will send response back to HTTP Port.

Step 2 : Send HTTP POST Request using POSTMAN or any other client.









We can check that given XML string is converted to JSON data string. XML repeating elements are converted to JSON array datatype. 

Input : 

<?xml version = "1.0" encoding = "UTF-8"?>
<Inventory>
 <CustomerDetails>
  <Customer>
   <customerId>01</customerId>
   <firstName>jon</firstName>
   <middleName>a</middleName>
   <lastName>doe</lastName>
   <contactDetails>
    <emailId>jon.a.doe@g.com</emailId>
    <modileNo>987654321</modileNo>
   </contactDetails>
  </Customer>
  <Customer>
   <customerId>01</customerId>
   <firstName>foo</firstName>
   <middleName>b</middleName>
   <lastName>bar</lastName>
   <contactDetails>
    <emailId>foo.b.bar@g.com</emailId>
    <modileNo>789654321</modileNo>
   </contactDetails>
  </Customer>
 </CustomerDetails>
</Inventory>

Output :

{
 "CustomerDetails": {
  "Customer": [{
   "customerId": "01",
   "firstName": "jon",
   "middleName": "a",
   "lastName": "doe",
   "contactDetails": {
    "emailId": "jon.a.doe@g.com",
    "modileNo": "987654321"
   }
  },
  {
   "customerId": "01",
   "firstName": "foo",
   "middleName": "b",
   "lastName": "bar",
   "contactDetails": {
    "emailId": "foo.b.bar@g.com",
    "modileNo": "789654321"
   }
  }]
 }
}


JSON to XML






We have successfully converted XML to JSON and vice versa.

Comments

Popular posts from this blog

Spring | Using TIBCO EMS with Spring framework

TIBCO | For Loop - Accumulate output

TIBCO | JNDI Server & JMS Instance creation