2016-06-23 51 views
1

我有下面提到的肥皂請求,我使用的是WSO2ESB 4.9
SOAP請求:WSO2ESB for each mediator,FOR EACH RESPONSE having/n/t extra with each element

<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonArray><jsonElement><a><s>as</s></a><b>Type1</b><c>C1</c><d><t>A1</t></d><e>e1</e></jsonElement><jsonElement><a><s>as</s></a><b>Type2</b><c>C2</c><d><t>A1</t></d><e>e1</e></jsonElement></jsonArray></soapenv:Body></soapenv:Envelope> 

我想迭代器來jsonElement/B,並得到JSON列表:["Type1", "Type2"]。但我得到以下列表:

[ 
    "\n\t\t\t\t\t\t\t\t\t\t\tType1\n\t\t\t\t\t\t\t\t\t", 
    "\n\t\t\t\t\t\t\t\t\t\t\tType2\n\t\t\t\t\t\t\t\t\t" 
] 

請任何方式來獲得所需要的清單。對於每個媒介:

<foreach expression="//jsonArray/jsonElement"> 
    <sequence> 
     <payloadFactory media-type="xml"> 
      <format> 
       <jsonElement> 
        $1 
       </jsonElement> 
      </format> 
      <args> 
       <arg expression="//b" evaluator="xml" /> 
      </args> 
     </payloadFactory> 
    </sequence> 
</foreach> 

回答

1

明白它的工作原理,在foreach <jsonElement>有空間和換行符。

工作代碼:

<foreach expression="//jsonArray/jsonElement"> 
    <sequence> 
     <payloadFactory media-type="xml"> 
      <format> 
       <jsonElement xmlns="">$1</jsonElement> 
      </format> 
      <args> 
       <arg expression="//b" evaluator="xml" /> 
      </args> 
     </payloadFactory> 
    </sequence> 
</foreach>