hello I have the following class mediator created through Carbon Studio:
package my.mediation;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class Auth extends AbstractMediator {
public boolean mediate(MessageContext context) {
// TODO Implement your mediation logic here
context.setProperty("message","hello world!" );
return true;
}
}
And the sequence is like:
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<property name="message" value="nothing" scope="default" />
<class name="my.mediation.Auth" />
<log>
<property name="Message******" expression="get-property('message')" />
</log>
</inSequence
> The problem is that instead of printing Message: "HelloWorld" it always print the text "nothing"...Any suggestion?
Your scenario is perfectly valid one and your configuration also seems to be fine.
I have tied your scenario and it works fine for me.
Following are my configurations.
Class Mediator:
package org.wso2.mediator;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class SampleMediator extends AbstractMediator {
public boolean mediate(MessageContext context) {
context.setProperty("Message", "HelloWorld!");
return true;
}
}
My proxy service:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SimpleProxy"
statistics="disable" trace="disable" transports="http,https">
<target>
<inSequence>
<log category="INFO" level="simple" separator=","/>
<property action="set" name="Message" scope="default"
type="STRING" value="DefaultMessage"/>
<class name="org.wso2.mediator.SampleMediator"/>
<log category="INFO" level="simple" separator=",">
<property expression="get-property('Message')" name="===========Message Value=========="/>
</log>
<drop/>
</inSequence>
</target>
</proxy>
When I invoke the proxy service without the class mediator, it prints
INFO - LogMediator To: /services/SimpleProxy.SimpleProxyHttpSoap12Endpoint,WSAction: urn:mediate,SOAPAction: urn:mediate,MessageID: urn:uuid:81150094-cbc4-44f7-83eb-251e28149564,Direction: request,===========Message Value========== = DefaultMessage
and when I invoke the proxy service with the class mediator it prints,
INFO - LogMediator To: /services/SimpleProxy.SimpleProxyHttpSoap12Endpoint,WSAction: urn:mediate,SOAPAction: urn:mediate,MessageID: urn:uuid:e3a04341-907c-40fe-9f58-5a10d2ce346a,Direction: request,===========Message Value========== = HelloWorld!
Hope this helps!
Harshana