I implemented a proxy service to cache the response from a back-end (rest) web-service. I have some treatments to do on the response of the EP, such as changing ContentType to application/xml, so I defined a "OnCacheHit" sequence, at the end of which I use send mediator to send the message back to the client. But the client receives an empty response (whether I call the service directly from my browser or from another Proxy Service).
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="PS_with_cache"
transports="https http local" startOnLoad="true" trace="disable"><description />
<target>
<inSequence>
<log level="full" category="DEBUG" xmlns="http://ws.apache.org/ns/synapse" />
<cache id="someCache" scope="per-host" collector="false"
hashGenerator="org.wso2.caching.digest.DOMHASHGenerator" timeout="10">
<onCacheHit>
<property name="ContentType" value="application/xml"
scope="axis2" type="STRING" />
<!-- I have to remove the To header, else it points towards PS_with_cache itself,
generating a "Malformed destination EPR" exception -->
<header name='To' action="remove"/>
<!-- logging the full payload of the message shows that
the cache returned whzat i expected -->
<log category="DEBUG" level="full" />
<send/>
</onCacheHit>
<implementation type="memory" maxSize="1000" />
</cache>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING" />
<send>
<endpoint key="Back_end_rest_endpoint" />
</send>
</inSequence>
<outSequence>
<property name="ContentType" value="application/xml" scope="axis2"
type="STRING" />
<cache id="someCache" scope="per-host" collector="true" />
<send />
</outSequence>
</target>
</proxy>
It works perfectly as long as the response is not in cache. A full log inside the onCacheHit sequence shows that the cache returns the expected response. So the problem lies in the subsequent "send".
My guess was that the message was treated inappropriately as a request rather than a response, so i tried to change the synapse.isresponse property but it changed nothing.
I really can't figure out what's happening here, thanks for answering...