WSO2 MSF4J在@Post中接收大数据

时间:2017-09-22 10:40:52

标签: rest post wso2 msf4j wso2msf4j

我们使用wso2微服务引擎作为WSO2 EI和DB之间的中间件。目标链MQ-> WSO EI-> msf4j-> DB。转移的DTO - 格式化的xml字符串,基本上不应该解析直到msf4j层。所以,对于所有这些只是字符串。有时这是一个很大的字符串。

我们的代码

@Path("/accountdao")
public class AccountDaoService implements Microservice {

@POST
@Path("/getbyparam")
@Produces(MediaType.TEXT_PLAIN)
public String getAllAccounts(@QueryParam("commandText") String commandText) {

之前我们在GET的样式调用中测试过它,我的意思是像

一样
URL url = new URL(serverURL + requestURL + "/?commandText=" + 
URLEncoder.encode(request,"UTF-8"));

在所有其他样式中,使用来自commons的HttpClient,我们没有在commandText中接收数据。

而且我发现,我不知道如何使用SoapUI传递大数据或只是清除java客户端..

使用小文本块(如200-300个字符)都可以,但是长度为6k,这已经是问题了。

是否可以在msf4j中处理大字符串,或者我们应该使用其他的字符串吗?

感谢。

PS 可能我们应该使用@FormParam&多部分/格式数据?

更新1

 <payloadFactory media-type="xml">
                <format>
                    <uri.var.commandText xmlns="">$1</uri.var.commandText>
                </format>
                <args>
                    <arg evaluator="xml" expression="get-property('uri.var.commandText')"/>
                </args>
            </payloadFactory>
            <call blocking="true" description="">
                <endpoint key="microserviceEP"/>
            </call>

和微服务代码

    @POST
    @Path("/getclientcontract")
    @Produces(MediaType.TEXT_PLAIN)
    public String getClientContract(@Context Request request) {

List<ByteBuffer> fullMessageBody = request.getFullMessageBody();
        StringBuilder sb = new StringBuilder();
        for (ByteBuffer byteBuffer : fullMessageBody) {
            sb.append(StandardCharsets.UTF_8.decode(byteBuffer).toString());
        }

        String commandText = sb.toString();

没关系,还是有更正确的方法?

0 个答案:

没有答案