Hi Maz, Since your requirement is to dynamically generate payload, You can use script mediator in this case.
This opther option is to use a class mediator [1]. However script mediator is preferred over class mediator. [1] https://docs.wso2.com/display/ESB481/Class+Mediator On Thu, Jan 8, 2015 at 2:27 AM, Maz Lakadia <[email protected]> wrote: > Hi, > > I am trying to use Payload Factory Mediator to change server responses. > Suppose I have 2 sorts of JSON objects my server can respond with: ball and > bat. > Now for the ball case, my response could look something like: > > {"ball": > {"weight": 152}, > {"radius": 46}, > {"colour":"white"} > } > > If the case of "ball" I want to change the response to something like: > > {"baseball": > {"colour":"white"}, > {"mass":152}, > } > > I know how to mediate a single resource like that. i.e. given the server > response is "ball" object, I can change it to what I want. The difficulty > arises if now I have a 2nd possible response from the server (a "bat" > object). I wish to perform a similar mediation on it, but it would have > different fields that need to be filled. Therefore my Payload Factory code > from the "ball" case will no longer work. How could I write the > configuration files such that for different resources ("bat","ball",etc) a > different template is used to fill in the data? Is it easier to use a > Script Mediator or some other sort of mediator for this purpose? > > Thanks, > Maz > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Best Regards, Malaka Silva Senior Tech Lead M: +94 777 219 791 Tel : 94 11 214 5345 Fax :94 11 2145300 Skype : malaka.sampath.silva LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77 Blog : http://mrmalakasilva.blogspot.com/ WSO2, Inc. lean . enterprise . middleware http://www.wso2.com/ http://www.wso2.com/about/team/malaka-silva/ <http://wso2.com/about/team/malaka-silva/> Save a tree -Conserve nature & Save the world for your future. Print this email only if it is absolutely necessary.
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
