Wso2 如何将响应从text/plain更改为text/xml
我有一个服务返回文本/普通内容。响应消息如下: “成功” 但在ESB4.0.3中,响应如下:Wso2 如何将响应从text/plain更改为text/xml,wso2,plaintext,Wso2,Plaintext,我有一个服务返回文本/普通内容。响应消息如下: “成功” 但在ESB4.0.3中,响应如下: <text xmlns="http://ws.apache.org/commons/ns/payload"><?xml version="1.0" encoding="UTF-8"?><message><MsgType>RESP</MsgType><ReturnCod
<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>
?xml version=“1.0”encoding=“UTF-8”?消息MsgTypeResp/MsgTypeReturnCode0/ReturnCodeReturnMessageSuccess/ReturnMessage/message
我在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>
您需要指定消息的ContentType。由于来自HTTP的输入将包含Soap信封和正文,因此您的内容将包含在这样的标记中 当您现在告诉您的端点消息的类型为text/plain时,PlainTextFormatter会将其转换为真实文本并将其发送给您的端点(axis2.xml只是配置文件-现在需要告诉您现在要使用PlainTextFormatter) 该行缺失:
<property name="ContentType" value="text/plain" scope="axis2"/>
我遇到了同样的问题,然后我设置了
<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>
Erro no processamento de XML:formataço incorreta Posiço:http://xxxxxxx/services/RESTE?tryit# Número da linha 1号,科鲁纳221:
tryitproxy错误h:status='SOAP信封错误'xmlns:h='0http://wso2.org/ns/TryitProxy'org.apache.axis2.AxisFault:com.ctc.wstx.exc.WstxUnexpectedCharException:prolog中的意外字符'r'(代码114);应为''at[row,col{unknown source}]:[1,1]/TryitProxyError----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^
p、 s:当我使用其他工具(如SOAPUI)时,它工作正常。我设置了ContentType,您可以看到新的服务配置。但是没有使用,响应是: