Vehicles registration services using REST services on government TAX department system. That REST services give the TAX information for the Vehicle.

{"Tax": {"Amount": 58963}}

Vehicles registration Depart planning to extend the service and expose as below.

{
     "VechileRegistrationTAX": 58963,
     "Currency": "LKR"
}

They will need transformation and valid the respond they collect from the TAX department. They will need simple proxy for this.

           <!—To validat the json—>

           <validate description="validating-be-respond">
                <schema
                     key="conf:schema/json/vehicles-registration-tax-json-schema.json" />

                 <on-fail>
                     <property description="set-error-message" name="custom-error-message"
                         scope="default" type="STRING" value="JSON Validation Failure from TAX API" />
                     <log level="custom">
                         <property name="validation-failure" value="Validation Failed..........." />
                     </log>
                     <sequence key="vehicles-registration-json-validation-failure-sequences" />
                 </on-fail>
             </validate>

<! – Build sample error message –>

<sequence name="vehicles-registration-json-validation-failure-sequences"
   trace="disable" xmlns="http://ws.apache.org/ns/synapse">
   <log level="custom">
     <property name="testing" value="failure in validation Common sequence"/>
   </log>
  <payloadFactory media-type="json">
     <format>
             {"error":true,
             "error-message":"$1"}
         </format>
     <args>
       <arg evaluator="xml" expression="get-property('custom-error-message')"/>
     </args>
   </payloadFactory>

   <send/>
</sequence>

image

<! - - Build message transformation – >

            <payloadFactory description="setting-out-json"
                 media-type="json">
                 <format>
                     {
                     "VechileRegistrationTAX":$1,
                     "Currency":"LKR"
                     }
                 </format>
                 <args>
                    <arg evaluator="json" expression="$.Tax.Amount" />
                 </args>
             </payloadFactory>


image

1

View comments

I am
I am
Archives
Total Pageviews
Total Pageviews
2 0 5 7 7 0 6
Categories
Categories
Loading