I built a GET REST webservice (Rest API) which has to return text/html.
Inside the sequence I have a Mediator where I invoke a webpage (like http://www.mypage.com or something), and get its contents into a String variable.
After that I need to do some string replacements in the content and send it back as text/html to the client.
The problem is that when I got it back in my page the esb has replaced all <html>
and other tags to <html>
tags. So the web browser does not render a html page, but just writes the tags in the page itself.
The main idea is that it works like a proxy to a servlet, where I call a servlet, get the response, do some string replacements inside de html and javascript that I got, and send it to client.
Here is the sequence xml:
<resource methods="GET" uri-template="/view">
<inSequence>
<log level="full"/>
<header name="To" action="remove"/>
<property name="URL" value="http://www.mypage.com"/>
<sequence key="MyMediator"/>
<property name="RESPONSE" value="true"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<enrich>
<source type="property" clone="true" property="RESPONSE_MSG"/>
<target type="body"/>
</enrich>
<send/>
</inSequence>
So, I put the string variable with the html (got from the mediator MyMediator, which is a java class and invoke the webpage www.mypage.com) into a property 'RESPONSE_MSG' and then try to write it to the body (enrich).
In this case I get an error, because the property I set is a String and not a XML.
If I use a payloadFactory instead of an enrich, then it will generate an XML and I will get the html tags with <html>
.
I would like to know an effective way where I can send the string variable from the mediator and it does not get transformed into some xml where all the html tags into the string gets replaced by <
and >
. Or I can send it like in the above code without getting any error. Do I have to use another type for the variable that I put in the property RESPONSE_MSG?
Thanks in advance!