Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WSO2 ESB版本4.7.0,简单的JSON到XML转换问题_Xml_Json_Wso2_Wso2esb_Wso2carbon - Fatal编程技术网

WSO2 ESB版本4.7.0,简单的JSON到XML转换问题

WSO2 ESB版本4.7.0,简单的JSON到XML转换问题,xml,json,wso2,wso2esb,wso2carbon,Xml,Json,Wso2,Wso2esb,Wso2carbon,我正在尝试熟悉WSO2 ESB 4.7.0。作为简单的测试,我想使用代理服务将JSON转换为XML。现在我已经理解了ESB将JSON隐式转换为XML。我创建了一个简单的中介,目的是将转换后的XML消息写入一个文件。不幸的是,JSON到XML转换的结果是空的(文件中没有数据)。我是否理解WSO2的JSON功能有什么问题,或者我的中介有什么问题 我的调解: <?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.

我正在尝试熟悉WSO2 ESB 4.7.0。作为简单的测试,我想使用代理服务将JSON转换为XML。现在我已经理解了ESB将JSON隐式转换为XML。我创建了一个简单的中介,目的是将转换后的XML消息写入一个文件。不幸的是,JSON到XML转换的结果是空的(文件中没有数据)。我是否理解WSO2的JSON功能有什么问题,或者我的中介有什么问题

我的调解:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="MockJsonTest" transports="http https" startOnLoad="true" trace="disable">
<target>
    <inSequence>
        <property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
        <property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
        <log level="full"/>
        <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
        <property name="transport.vfs.ReplyFileName" value="filename.xml" scope="transport" type="STRING"/>
        <send>
            <endpoint>
                <address uri="vfs:file:///C:/wso2">
                    <timeout>
                        <duration>0</duration>
                        <responseAction>discard</responseAction>
                    </timeout>
                </address>
            </endpoint>
        </send>
    </inSequence>
    <outSequence/>
    <faultSequence/>
</target>
在axis2.xml中,我尝试了JSON的两种格式:

    <!--messageFormatter contentType="application/json"
                      class="org.apache.axis2.json.JSONMessageFormatter"/-->
    <messageFormatter contentType="application/json"
                      class="org.apache.axis2.json.JSONStreamFormatter"/>

亲切问候,


Heiko

我测试了您的场景,得到了正确的输出,如下所示

<kind>plus#person</kind>
plus#个人
下面是我的代理服务

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="MockJsonTest"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
         <property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
         <log level="full"/>
         <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
         <property name="transport.vfs.ReplyFileName"
                   value="filename.xml"
                   scope="transport"
                   type="STRING"/>
         <send>
            <endpoint>
               <address uri="vfs:file:///home/user/test">
                  <timeout>
                     <duration>30000</duration>
                     <responseAction>discard</responseAction>
                  </timeout>
               </address>
            </endpoint>
         </send>
      </inSequence>
   </target>
   <description/>
</proxy>

30000
丢弃
代理服务中似乎存在一些小的xml格式错误。将其与上述内容进行比较。在源代码视图中指定代理时,请始终单击末尾的“切换到设计视图”。然后,如果有任何格式错误,它会提醒您

我使用了与您提供的相同的curl命令。我在axis2.xml中有ESB 4.7.0的默认JSON消息格式化程序和构建器,如下所示

<!--JSONBuilder Message Formatters-->
        <messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
        <!--messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONStreamFormatter"/-->
        <messageFormatter contentType="application/json/badgerfish"
                          class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
        <messageFormatter contentType="text/javascript"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>

我测试了您的场景,得到了正确的输出,如下所示

<kind>plus#person</kind>
plus#个人
下面是我的代理服务

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="MockJsonTest"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
         <property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
         <log level="full"/>
         <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
         <property name="transport.vfs.ReplyFileName"
                   value="filename.xml"
                   scope="transport"
                   type="STRING"/>
         <send>
            <endpoint>
               <address uri="vfs:file:///home/user/test">
                  <timeout>
                     <duration>30000</duration>
                     <responseAction>discard</responseAction>
                  </timeout>
               </address>
            </endpoint>
         </send>
      </inSequence>
   </target>
   <description/>
</proxy>

30000
丢弃
代理服务中似乎存在一些小的xml格式错误。将其与上述内容进行比较。在源代码视图中指定代理时,请始终单击末尾的“切换到设计视图”。然后,如果有任何格式错误,它会提醒您

我使用了与您提供的相同的curl命令。我在axis2.xml中有ESB 4.7.0的默认JSON消息格式化程序和构建器,如下所示

<!--JSONBuilder Message Formatters-->
        <messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
        <!--messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONStreamFormatter"/-->
        <messageFormatter contentType="application/json/badgerfish"
                          class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
        <messageFormatter contentType="text/javascript"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>