如何强制 WSO2 调用中的文本/纯文本到端点 [英] how to force text/plain in WSO2 call to an endpoint

查看:9
本文介绍了如何强制 WSO2 调用中的文本/纯文本到端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个序列中有一个丰富的中介,它在纯文本中有一个值.我已经用日志验证了这个值,并确保它是一个文本.但是当我在丰富(见下文)之后进行调用时,API 将有效负载作为 JSON 接收,其密钥始终为test":然后是纯文本值.

I have an enrich mediator in a sequence which has a value in a plain text. I have verified the value with log and ensured it is a text. But when I do the call after the enrich (see below) the API received the payload as a JSON with key always as "test": and then the plaintext value.

下面的 API 需要任何值,它只是将正文保存到文件中.当我尝试在调用状态消息 type=text/plain 之前设置属性时,它只是挂起,不进行调用吗?

The API below expects any values, it just saves the body to a file. When I try to set a property before the call to state message type=text/plain it just hangs, does not do the call?

问题:WSO2 调解器(wso2 框架)本质上是否期望主体是 JSON 或 XML?不允许使用文本/纯文本.如果这是真的,那么我必须更改我的 API 来处理我认为的这个问题.

QUESTION: Does WSO2 mediator (wso2 framework) by nature expects the body to be either be JSON or XML? NOT Text/Plain allowed. If this is true, then I have to change my API to handle this issue I Think.

如果有人能回答这个问题,我想我会知道该怎么做.因为当我使用具有相同选项的 java 类调解器调用相同的 API 时,它可以正常工作.

If someone can answer that question, I think I will know what to do. Because when I call the same API using a java class mediator with same options it works fine.

<call>
    <endpoint>
       <http method="POST" uri-template="http://xxxxxxx.38:8280/writefile"/>
    </endpoint>
</call>

推荐答案

感谢您的更新.我之前尝试过,当我发现进程挂起并且不会调用 api 时.以下是我们为使其工作所做的工作:

Thanks for the update. I had tried that before, when I had that the process was hanging and would not call the api. Here is what we did for it to work:

<payloadFactory media-type="xml">
        <format>
            <text xmlns="http://ws.apache.org/commons/ns/payload">$1</text>
        </format>
        <args>
            <arg evaluator="xml" expression="get-property('fileContent')"/>
        </args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="text/plain"/>

感谢各位更新.第一次提出问题,很高兴看到尽快得到答复.将尽力贡献我的学习并尽力提供帮助.

Thanks for the update folks. First time asking a questions and good to see getting response ASAP. Will try to contribute my learning and try to help .

这篇关于如何强制 WSO2 调用中的文本/纯文本到端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆