0

I have simple scenario, I have WSO2 ESB instance and I built sequence for processing message, where one step of this sequence is content enrichement of message body. Informations, which should be added into enriched body, are available over REST webservice deployed somewhere else on application server. I wasn't able to find working solution with default mediator set (I know, there is posibility to write my own mediator). Enrich mediator itself doesn't have this capability. I found similar solution in book from PacktPub, sample is called content enricher, but it uses database () as source for future enrichement and Enrich mediator isn't used there. Is there any solution for this or I am on wrong way?

Thanks in advance.

Community
  • 1
  • 1
Thelvyn
  • 45
  • 1
  • 6

1 Answers1

0

For my understanding, what you are trying is, at some point you want to alter the message(enrich) using some data, But that required data, you need to get from an REST endpoint.

If this is the case;

What you have to do is,

Before enriching, call your REST endpoint and get the response first. From that response, extract the data you needed. Use that extracted data in the enrich mediator to enrich your new message payload.

This type of scenario is called service chaining. You have to use proper mediators in place to achieve your final requirement.

Edit:
//I want to have still the same message at the end of chain//

1)So, store your initial message in a property mediator(with type=OM)

2)Then call your REST endpoint and get data and extract needed value.

3) Then use enrich mediator to enrich the previously stored message.

4)Then again use enrich mediator to convert that property to soapbody

5)Send that to client.

Ratha
  • 9,434
  • 17
  • 85
  • 163
  • Thanks, for your reply. I've tried this sample before, but I wasn't able to handle my scenario this way. All service chaning samples describes a little bit different situation, they work with different messages through the chain, they take response from first and make new request to second service in the chain. I need something else. I want to have still the same message at the end of chain, but enriched with some data which I will get from REST webservice. Maybe I didn't understand well how to store information from response and keep original message in the chain. – Thelvyn Mar 27 '14 at 06:49
  • I edited my above answer about how to achieve your requirement. – Ratha Mar 27 '14 at 21:02
  • Thank you, with your advice I was be able to realize my scenario, but using enrich mediators needs much more knowlede of XPATH (or XSLT) and I did the enrichment with custom class mediators in Java. – Thelvyn Apr 03 '14 at 05:47
  • BTW, would you have some complex scenario realized in WSO2 ESB to share (samples distributed with ESB are too simple)? – Thelvyn Apr 03 '14 at 05:55