|
Hi Hadrian, Thanks for your offer of help. I have followed
the builtin log mediator and developed a mediator. In mediate method I am doing
this: public
boolean mediate(MessageContext
synCtx) { //
check if it is in request phase if(!synCtx.isResponse()) {
// if request, set property value synCtx.setProperty("Id",
new Long(1)); }
else {
// response phase, retrieve value Long i
= (Long) synCtx.getProperty("Id");
// I am getting i as null here if(i != null) { log.info("Id:
" + i.longValue()); } else { log.info("i is null"); } } return true; } The
value of i is null in response phase. I have gone
through the debugger as well and I see i as null
during response. I
am attaching synapse.xml file with this mail. The
mediator tag is <myMediator/> which is below
<log../> tag. Sanjesh From: Hadrian Zbarcea
[mailto:[EMAIL PROTECTED] Hi Sanjesh, On 8/15/06, Sanjesh
Pathak <[EMAIL PROTECTED]>
wrote: Hi, I
have created a new mediator and it is working fine. Now I want to set a
property value in the request phase of the mediate method and retrieve it in
response phase. What is the right approach? I
tried using msgContext:setProperty() in request phase and when I retrieve it
using msgContext :getPorperty() I am getting a null value. Sanjesh |
<synapse xmlns="http://ws.apache.org/ns/synapse"> <definitions> <sequence name="stockquote"> <!-- set the To address to the real endpoint --> <header name="To" value="http://www.webservicex.net/stockquote.asmx"/> <!-- check if the symbol is MSFT --> <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://services.samples/xsd"> <!-- if it is throw a fault --> <makefault> <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/> <reason value="Isn't there a Windows API for that?"/> </makefault> </filter> </sequence>
</definitions>
<rules>
<!-- now log the message using log4j -->
<log level="full"/>
<myMediator/>
<!-- Check if the URL matches the stockquote gateway/dumb case -->
<filter source="get-property('To')" regex=".*/StockQuote.*">
<sequence ref="stockquote"/>
</filter>
<!-- check if the URL matches the virtual url - either the proxy or ws-add case -->
<filter source="get-property('To')" regex="http://.*stockquotes.*">
<sequence ref="stockquote"/>
</filter>
<!-- send the message on -->
<send/>
</rules>
</synapse>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
