Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6821199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:31:00+00:00 2026-05-26T21:31:00+00:00

In Mule, currently I am using a custom transformer JavaObjectToJSON (as a Response Transformer)

  • 0

In Mule, currently I am using a custom transformer “JavaObjectToJSON” (as a Response Transformer) to convert a POJO to JSON i.e. my component class returns a Java Object (List or HashMap) and this transformer converts it into JSON and returns the result.

My code is like :

<flow name="OfferingDetails">
    <http:inbound-endpoint address="http://localhost:1212/jcore/offering/details" 
transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJSON">  
    </http:inbound-endpoint>

    <component class="main.java.com.raman.jcore.OfferingDetails"/>
</flow>

Now Suppose I want to return the result in XML. For this i can use another custom transformer “JavaObjectToXML” that can do the same in similar manner.


But my query how can i do this dynamically. Like if i give choice to Client on how it wants the data. And he can hit the URL like

  • “http://localhost:1212/jcore/offering/details/?response=json&#8221;
  • “http://localhost:1212/jcore/offering/details.json/&#8221;

OR

  • “http://localhost:1212/jcore/offering/details/?response=xml&#8221;
  • “http://localhost:1212/jcore/offering/details.xml/

And so i would be able to change the transformer at runtime, and return the result in corresponding notation. Is there any way to do it..??

or apart from Changing Transformer, any other workaround ??

Please Help me. I am Stuck in this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:31:00+00:00Added an answer on May 26, 2026 at 9:31 pm

    Use a choice routing message processor to select the right transformer in the response phase.

    Something in the line of:

    <flow name="OfferingDetails">
      <http:inbound-endpoint address="http://localhost:1212/jcore/offering/details"
                             transformer-refs="HttpParams" />  
    
      <component class="main.java.com.raman.jcore.OfferingDetails"/>
    
      <response>
        <choice>
          <when expression="message.getInboundProperty('http.request.path').contains('json')" evaluator="groovy">
            <transformer ref="JavaObjectToJSON" />
          </when>
          <otherwise>
            <transformer ref="JavaObjectToXML" />
          </otherwise>
        </choice>
      <response>
    </flow>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a java class as a mule endpoint that writes a message
I have a Flow in MULE which contains a HTTP inbound and component class
I have a backend system that currently returns a domain object. I want to
We're securing Mule services using the Spring Security Framework, and some of the services
I have a jruby/rails app using: jruby 1.4.0 Rails 2.3.5 ActiveMQ 5.3.0 Mule ESB
How does RabbitMQ compare to Mule, I am going to build an application using
I am exposing a CXF service using Mule ESB and i need to pass
I'm currently using JerseyTest w/ Grizzly embedded server to test some code. I do
I'm writing a mule application that implements some web services using Jersey. I'd like
We are using org.mule.tck.FunctionalTestCase for test cases. Its an abstract JUnit test case. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.