我有一个服务返回text / plain内容。响应消息如: RESP0Success” 但在ESB4.0.3中,响应如下:
<text xmlns="http://ws.apache.org/commons/ns/payload"><?xml version="1.0" encoding="UTF-8"?><message><MsgType>RESP</MsgType><ReturnCode>0</ReturnCode><ReturnMessage>Success</ReturnMessage></message>
</text>
我在axis2.xml中设置了构建器和格式化程序。但没用。
<messageBuilder contentType="text/plain"
class="org.apache.axis2.format.PlainTextBuilder"/>
<messageFormatter contentType="text/plain"
class="org.apache.axis2.format.PlainTextFormatter"/>
anyxone可以告诉我如何在axis2.xml中设置构建器和格式化程序吗?我的服务配置是:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TextPlain" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="ContentType" value="text/plain" scope="axis2" />
<log level="full" />
</inSequence>
<outSequence>
<log level="full" />
<property name="ContentType" value="text/plain" scope="axis2" />
<send />
</outSequence>
<endpoint>
<address uri="http://172.20.28.206:8080/AAAService/recieveMsg" format="pox">
</address>
</endpoint>
</target>
</proxy>
答案 0 :(得分:1)
我遇到了同样的问题,然后我设置了
<property name="messageType" value="text/plain" scope="axis2"/>
现在它可以工作,如果我从URL调用它,它将只返回文本。
<proxy xmlns="http://ws.apache.org/ns/synapse" name="RESTE" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
</inSequence>
<outSequence>
<log level="full"/>
<property name="messageType" value="text/plain" scope="axis2"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://10.15.21.189:8180/contadorServicos/ola-mundo"/>
</endpoint>
</target>
<parameter name="serviceType">proxy</parameter>
<description></description>
</proxy>
不幸的是,Tryit功能停止工作,现在它给出了以下错误。
<parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">Erro no processamento de XML: formatação incorreta Posição: http://xxxxxxx/services/RESTE?tryit# Número da linha 1, coluna 221:
<sourcetext><TryitProxyError h:status='SOAP envelope error' xmlns:h='http://wso2.org/ns/TryitProxy'>org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'r' (code 114) in prolog; expected '<'at [row,col {unknown-source}]: [1,1]</TryitProxyError> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^</sourcetext>
</parsererror>
p.s:当我使用其他工具如SOAPUI时,它可以正常工作。
答案 1 :(得分:0)
您需要指定邮件的ContentType。由于来自HTTP的输入将包含Soap信封和正文,因此您的内容将包含在此类标记内。
当您现在告诉您的端点,消息是text / plain类型时,PlainTextFormatter会将其转换为真实文本并将其发送到您的端点(axis2.xml只是配置 - 现在您需要告诉您想立即使用PlainTextFormatter)
缺少此行:
<property name="ContentType" value="text/plain" scope="axis2"/>