wso2 esb json to json converting double quotes mis

2019-09-10 06:24发布

I have a problem in converting json to json in wso2 esb, actually I'm using payload factory in a proxy and I call the proxy with rest and json content. Here is my integration flow, I call a proxy and the proxy sends the request(with json content) to a jms message store then, I defined a message processor to consume messages from message store and send them to a defined endpoint(.net web api). but the problem is strings with numbers automatically get converted as integer elements: "orderId": 10000 ( I want it to be string "orderId": "10000") , but when I send the request directly from proxy to my end point (without using message broker) it works correctly. Could you please help me solve this problem?

3条回答
甜甜的少女心
2楼-- · 2019-09-10 06:42

For more details refer to my question with more details on this problem, and looks like this is a bug in wso2 esb 4.9.0 wso2 jira

查看更多
3楼-- · 2019-09-10 06:49

For your problem need to change a JSON Message Formatters. please follow the below steps for that.

  • change your working directory to [ESB Home]/repository/conf/axis2/axis2.xml

  • then you need to change JSON Message Formatters instead of JsonStreamFormatter use org.apache.axis2.json.JSONMessageFormatter.

  <!--messageFormatter contentType="application/json"                                class="org.apache.synapse.commons.json.JsonStreamFormatter"/-->
    <messageFormatter contentType="application/json"
                              class="org.apache.axis2.json.JSONStreamFormatter"/>
查看更多
该账号已被封号
4楼-- · 2019-09-10 06:56

You can use the following builder and formatter in axis2.xml

org.apache.synapse.commons.json.JsonStreamBuilder
org.apache.synapse.commons.json.JsonStreamFormatter

Remove existing builder and formatter for the "application/json" and add the below.

Add under Formaters section

<messageFormatter contentType="application/json"
                          class="org.apache.synapse.commons.json.JsonStreamFormatter"/>

Add under Builders section

 <messageBuilder contentType="application/json"
                            class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
查看更多
登录 后发表回答