WSO2:转换响应 xml

WSO2 : Transforming response xml

我想将此 xml 回复变成更易于阅读的内容。

<?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”的值,我可以做得更好:

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

然后将它变成 json 响应,但我看不到...我只是得到所有输出或在 json 流中但包含所有内容,这是不可用的。

创建一个具有以下内容的外部调解序列并将其附加到相应的 API 并尝试该场景。这是为了提取 xmlpres 内容并将其作为响应发送给客户端

<?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>

希望这可以帮助您相应地提取和发送响应。