如何在wso2 esb中更改标题标签

时间:2018-07-18 14:19:55

标签: wso2 wso2esb

我从数据服务中获取数据,然后调用XSLT中介程序来生成我的xml。

我的xml如下。

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP:Body>
        <ADD_STUDENT>
                <name>Joe Average</name>
                <age>21</age>

               <major>Biology</major>

        </ADD_STUDENT>
    </SOAP:Body>
</SOAP:Envelope>

但是ADD_STUDENT标记取决于上下文变量中的某些值。对于一个条件,其ADD_STUDENT否则为CHANGE_STUDENT。

我如何在WSO2 ESB中实现它?我可以做两个不同的xslt替代者,并使用过滤器调用xslt中介器。有没有办法更改此标签并在儿童时期附加学生数据?

3 个答案:

答案 0 :(得分:0)

在过滤条件之后,您可以使用有效负载中介器,因此在then中,您可以像

那样构造响应
 <ADD_STUDENT>
$1
 </ADD_STUDENT>

where $1 is $body/ADD_STUDENT/* 

在其他情况下,应该类似于

<CHANGE_STUDENT>
$1
</CHANGE_STUDENT>
 where $1 is $body/ADD_STUDENT/* 

答案 1 :(得分:0)

您可以将参数传递给XSLT。因此,将上下文值作为参数传递给XSLT,然后在XSLT中使用xsl:if

答案 2 :(得分:0)

如果要在xslt中传递参数,可以按照以下步骤进行操作:

在xslt介体调用中添加一个属性:

 <xslt  key="gov:services/jan/transformstuff.xsl" source="/soapenv:Envelope"> 
     <property  name="yourParam" expression="get-property('someProperty')" />
 </xslt>

在xslt中,您需要使用xsl:param声明参数,然后使用$paramName访问它,因此:

<xsl:stylesheet version="2.0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="yourParam" />

<xsl:template match="whatever" >
    <xsl:choose>
        <xsl:when test="$yourParam = 'jocket'">
         (do stuff)