WSO2:转换响应xml [英] WSO2 : Transforming response xml

查看:26
本文介绍了WSO2:转换响应xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将此 xml 响应转换为更易于阅读的内容.

I would like to turn this xml response into something more easily readable.

<?xml version="1.0" encoding="ISO-8859-1"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<soap:Body>
    <executeResponse xmlns="urn:GCE">
        <BusinessViewServiceexecuteOut xmlns="http://www.generix.fr/technicalframework/businesscomponent/applicationmodule/common" xmlns:ns2="http://www.generixgroup.com/processus/configuration/scheduler" xmlns:ns3="http://www.generix.fr/technicalframework/business/service/common">
            <xmlpres>&lt;?xml version = '1.0' encoding = 'UTF-8'?> &lt;VueTable type="View" name="Table" habctr="true" total_business_row="2" nbline="400" confNbline="400" numpage="1" nbpage="1">
           &lt;JTblView name="JTblView" type="ViewObject" maxfetchsize="999" maxfetchsizeexceeded="false">
              &lt;JTblViewRow current="true" type="ViewRow" index="1" business_row_index="1">
                 &lt;Cletbl precision="6" type="VARCHAR" pk="true">
                    &lt;business_data>N&lt;/business_data>
                 &lt;/Cletbl>
                 &lt;Codtbl precision="6" type="VARCHAR" pk="true">
                    &lt;business_data>001&lt;/business_data>
                 &lt;/Codtbl>
                 &lt;Lib1 precision="30" type="VARCHAR">
                    &lt;business_data>Non&lt;/business_data>
                 &lt;/Lib1>
                 &lt;Lib2 precision="30" type="VARCHAR">
                    &lt;business_data/>
                 &lt;/Lib2>
                 &lt;Lir precision="10" type="VARCHAR">
                    &lt;business_data>Non&lt;/business_data>
                 &lt;/Lir>
              &lt;/JTblViewRow>
              &lt;JTblViewRow type="ViewRow" index="2" business_row_index="2">
                 &lt;Cletbl precision="6" type="VARCHAR" pk="true">
                    &lt;business_data>O&lt;/business_data>
                 &lt;/Cletbl>
                 &lt;Codtbl precision="6" type="VARCHAR" pk="true">
                    &lt;business_data>001&lt;/business_data>
                 &lt;/Codtbl>
                 &lt;Lib1 precision="30" type="VARCHAR">
                    &lt;business_data>Oui&lt;/business_data>
                 &lt;/Lib1>
                 &lt;Lib2 precision="30" type="VARCHAR">
                    &lt;business_data/>
                 &lt;/Lib2>
                 &lt;Lir precision="10" type="VARCHAR">
                    &lt;business_data>Oui&lt;/business_data>
                 &lt;/Lir>
              &lt;/JTblViewRow>
           &lt;/JTblView>
        &lt;/VueTable></xmlpres>
        </BusinessViewServiceexecuteOut>
    </executeResponse>
</soap:Body></soap:Envelope>

至少如果我能提取xmlpres"的值,我能做得更好:

At least if I could extract what's in the value of "xmlpres", the better I could do:

<table><row><code></code><libelle></libelle/></row></table>

然后将其转换为 json 响应,但我看不到...我只是获取所有输出或在 json 流中但包含所有内容,这是不可用的.

To then turn it into a json response but I can't see ... I just get all the output or in json stream but with everything , which is not usable.

推荐答案

使用以下内容创建一个外中介序列并将其附加到相应的 API 并试用该方案.这是提取 xmlpres 内容并将其作为响应发送给客户端

Create an out-mediation sequence with the following content and attach it to the respective API and try out the scenario. This is to extract the xmlpres content and send that as the response to the client

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="out-sequence">
    
    <!-- extract the xmlpres content and store as OM element -->
    <property name="XMLBody" 
        expression="$body//soap:Body//generic:xmlpres" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:gce="urn:GCE" 
        xmlns:generic="http://www.generix.fr/technicalframework/businesscomponent/applicationmodule/common" type="OM" />
    
    <!-- pass the extracted property as response body -->
    <enrich>
        <source type="property" property="XMLBody" />
        <target type="body" />
    </enrich>
</sequence>

希望这有助于您相应地提取和发送响应.

Hope this helps you to extract and send the response accordingly.

这篇关于WSO2:转换响应xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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