如何使用 wso2 esb 中的类中介器将响应作为字符串发送 [英] how to send response as String using class mediator in wso2 esb
问题描述
在我的项目中,我创建了一些代理.传输类型是 tcp.我的回答是
In my project I created some proxy.There transport type is tcp. My response is
{
"BillingSystem": {
"request_id": "20114140080000011479122000",
"request_timestamp": "12102012121200",
"response_timestamp": "12102012121300",
"action": "AddSubscription",
"username": "Cellcard ",
"result_code": "0",
"result_desc": "Success"
}
}
我使用类中介器捕获此响应并使用该响应创建 WZ2OCS2:1:14:14008:1:@1479122000#.我需要将此字符串发送到 tcp 客户端.我在类 Meditor 中设置了这个 String
I catch this response using class mediator and create WZ2OCS2:1:14:14008:1:@1479122000# using that response. I need to send this string to tcp client. I set this String in the class meditor
context.setProperty("responseClientValue", responseClientValue);
在类中介器中设置此值后,我使用了有效负载工厂中介器,并在该属性中介器之后使用.
After set this value in class mediator I used payload factory mediator and after that property mediator.
<payloadFactory description="" media-type="xml">
<format>
<name xmlns="">$1</name>
</format>
<args>
<arg evaluator="xml" expression="get-property('responseClientValue')"/>
</args>
</payloadFactory>
财产中介
<property name="messageType" scope="axis2" type="STRING" value="application/text"/>
当我运行项目时它的显示xml代码
When I run project Its show xml code
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><name>WZ2OCS2:1:14:14008:1:@1479122000#</name></soapenv:Body></soapenv:Envelope>?
这是我的代理服务
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="SurepayBillingErrorHandlingProxy" startOnLoad="true" transports="tcp" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<class description="" name="esb.cellcard.billing.SurepayMediator"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<send>
<endpoint key="SurpayBillingEP"/>
</send>
</inSequence>
<outSequence>
<class name="esb.cellcard.billing.ResponseRequestId"/>
<payloadFactory description="" media-type="xml">
<format>
<name xmlns="">$1</name>
</format>
<args>
<arg evaluator="xml" expression="get-property('responseClientValue')"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/text"/>
<send/>
</outSequence>
<faultSequence/>
</target>
<parameter name="transport.tcp.responseClient">true</parameter>
<parameter name="transport.tcp.inputType">string</parameter>
<parameter name="transport.tcp.recordDelimiter">?</parameter>
<parameter name="transport.tcp.contentType">text/plain</parameter>
<parameter name="transport.tcp.port">6050</parameter>
<parameter name="transport.tcp.recordDelimiterType">character</parameter>
</proxy>
如何只获取字符串值.谢谢
How can I get only string value. Thank you
推荐答案
像这样改变你的payloadFactory:
Change your payloadFactory like this :
<payloadFactory>
<format>
<text xmlns="http://ws.apache.org/commons/ns/payload">$1</text>
</format>
<args>
<arg evaluator="xml" expression="$ctx:responseClientValue"/>
</payloadFactory>
像这样更改属性 messageType :
Change property messageType like this :
<property name="messageType" scope="axis2" type="STRING" value="text/plain"/>
(参见axis2.xml,默认情况下,PlainTextFormatter 类与 text/plain 相关联:<messageFormatter contentType="text/plain" class="org.apache.axis2.format.PlainTextFormatter"/>
)
(see axis2.xml, by default, the PlainTextFormatter class is associated with text/plain : <messageFormatter contentType="text/plain" class="org.apache.axis2.format.PlainTextFormatter"/>
)
这篇关于如何使用 wso2 esb 中的类中介器将响应作为字符串发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!