从WSO2代理向ActiveMQ发布纯文本
我是WSO2和ActiveMQ的新手,我一直在尝试实现看似简单的消息转换,但没有成功。 我需要在WSO2上公开一个web服务,它只接受一个特定输入参数的值(三个输入参数中的一个), 并将该值作为纯文本字符串转发到ActiveMQ队列。所以,没有后端服务,没有对流程的响应, 在发布到队列之前,只需要进行简单的单向转发操作,提取值并转换为纯文本。 我已经通过了代理示例和很多google搜索,但是,我能做到的最多就是在队列中获得所需的值, 但作为一种痘,这并不令人满意。 实际上我怀疑WSO2是否能够发布纯文本字符串, 然而,有些文章中,人们发誓说它几乎可以做任何可以想象的事情,只是他们没有确切解释如何做 我要做的是使用PayloadFactory中介提取所需的值“arg2”, 进入从WSO2代理向ActiveMQ发布纯文本,wso2,activemq,esb,Wso2,Activemq,Esb,我是WSO2和ActiveMQ的新手,我一直在尝试实现看似简单的消息转换,但没有成功。 我需要在WSO2上公开一个web服务,它只接受一个特定输入参数的值(三个输入参数中的一个), 并将该值作为纯文本字符串转发到ActiveMQ队列。所以,没有后端服务,没有对流程的响应, 在发布到队列之前,只需要进行简单的单向转发操作,提取值并转换为纯文本。 我已经通过了代理示例和很多google搜索,但是,我能做到的最多就是在队列中获得所需的值, 但作为一种痘,这并不令人满意。 实际上我怀疑WSO2是否能够发
元素(因为PayloadFactory坚持XML或JSON格式,不允许纯文本)。
然后我将该元素发送到队列。问题#1是WSO2能否以某种方式自动将xml转换为纯文本?
目前我认为没有
因此,在发送之前,我尝试了很多方法,在没有任何xml标记的情况下获取该值,
主要使用Enrich中介甚至Javascript,但在某个时刻,事情会失败——要么WSO2不让我定义这样的中介,
或者它将无法按预期/要求执行,或者在运行时失败。
调解人也没有得到真正明确的解释——“来源”是什么意思,
“目标”是什么?有了所有这些选项——无论我选择了什么选项,我从未见过调解人对我的信息做过任何改变。
请问我做错了什么?:)
下面是我当前的WSO2代理定义,它现在包含了我迄今为止从网上编译的几乎所有内容,
但它仍然只将值格式发布到队列-因此,这只是我迄今为止尝试的一个示例:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="VomsXdrPlain"
transports="http"
statistics="disable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<!-- first, the extraction -->
<payloadFactory media-type="xml">
<format>
<xdr xmlns="">$1</xdr>
</format>
<args>
<arg xmlns:xsd="http://api.service.com/"
evaluator="xml"
expression="//xsd:arg2"/>
</args>
</payloadFactory>
<!-- the following was added out of desperation -->
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="FORCE_POST_PUT_NOBODY"
value="true"
scope="axis2"
type="BOOLEAN"/>
<!-- here the idea was to put the value into a property, so it might be used in the Enrich mediator -->
<property name="xdrTicket"
expression="//xdr/text()"
scope="default"
type="STRING"/>
<!-- how to use the Enrich mediator properly for this purpose? -->
<enrich>
<source type="property" clone="true" property="xdrTicket"/>
<target type="body"/>
</enrich>
<!-- then I tried scripting... but the setPayLoadXML method also insists on tags so I've put "abc" -->
<script language="js">
var xmlPayload = mc.getPayloadXML();
var xdrTick = xmlPayload.substr(0,36);
mc.setPayloadXML(<abc>{xdrTick}</abc> );
</script>
<!-- this is posting to the queue and it works, but again, allowed formats are only POX, SOAP, REST, or AS-IS... but no PLAIN TEXT -->
<send>
<endpoint>
<address uri="jms:/VomsXdrService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"
format="pox"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules xmlns="">
<jmsProperty>contentType</jmsProperty>
<default>text/plain; charset=ISO-8859-1</default>
</rules>
</parameter>
<parameter name="ContentType" value="text/plain"/>
<parameter name="transports">jms</parameter>
<description/>
</proxy>
$1
很抱歉,messageType属性定义丢失,我已更新了答案
<body>
<p:writeXDRRequest xmlns:p="http://api.service.com/">
<xsd:arg0 xmlns:xsd="http://api.service.com/">VOMS</xsd:arg0>
<xsd:arg1 xmlns:xsd="http://api.service.com/">SDR</xsd:arg1>
<xsd:arg2 xmlns:xsd="http://api.service.com/">1.0|321|2014-09-24T13:25:19.183+0000</xsd:arg2>
</p:writeXDRRequest>
</body>
1.0|321|2014-09-24T13:25:19.183+0000
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="VomsXdrPlain"
transports="http"
statistics="disable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<text xmlns="http://ws.apache.org/commons/ns/payload">$1</text>
</format>
<args>
<arg xmlns:xsd="http://api.service.com/"
evaluator="xml"
expression="//xsd:arg2"/>
</args>
</payloadFactory>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="messageType" value="text/plain; charset=windows-1252" scope="axis2"/>
<!-- this is posting to the queue and it works, but again, allowed formats are only POX, SOAP, REST, or AS-IS... but no PLAIN TEXT -->
<send>
<endpoint>
<address uri="jms:/dynamicQueues/TestQueue?transport.jms.ConnectionFactory=myQueueConnectionFactory"/>
</endpoint>
</send>
</inSequence>
</target>
<description/>
</proxy>