wso2 esb类调解员

时间:2012-09-06 14:36:23

标签: wso2 wso2esb esb mediator

你好我有通过Carbon Studio创建的以下类mediator:

 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;
        }

}

序列如下:

<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

&GT; 问题是,而不是打印消息:“HelloWorld”它总是打印文本“没有”...任何建议?

2 个答案:

答案 0 :(得分:3)

您的方案完全有效,您的配置似乎也没问题。

我已经把你的情景绑定了,它对我来说很好。

以下是我的配置。

班级调解员:

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;
    }
}

我的代理服务:

<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>

当我在没有类介体的情况下调用代理服务时,它会打印

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

当我使用类介体调用代理服务时,它会打印,

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!

希望这有帮助!

Harshana

答案 1 :(得分:1)

问题基于 log4j.properties 。你的课程在my.mediation包中;在log4j.properties中不存在。您需要转到 YOUR_WSO2 / lib / log4j.properties 并添加命名空间/包的日志级别:

...
log4j.logger.org.wso2=INFO
log4j.logger.my.mediation=DEBUG

在这里,您还可以看到为什么Harashana的示例有效 - 他只是将包更改为org.wso2 - 您不应该为自己的自定义调解器执行此操作。