如何丰富OM属性中的节点值?

时间:2015-11-30 08:08:44

标签: wso2 wso2esb

是否可以使用rich mediator来丰富特定的节点值?

我的目标是丰富这个xpath:

$ctx:OriginalPayload//Partner[identifiers/businessId = $ctx:CorrelationId]/identifiers/otherId

我试过这些例子:

$ctx:OriginalPayload//Partner/identifiers/otherId
//Partner/identifiers/otherId
//Partner/identifiers/otherId/text()
//Partner/identifiers/otherId/node()

所有人都给了我这个错误:

ERROR - EnrichMediator Invalid Target object to be enrich.

我使用这种语法:

<enrich>
    <source xpath="//plat:CustomerAccountId"/>
    <target xpath="//Partner/identifiers/otherId"/>
</enrich>

以下是我试图丰富的有效载荷:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://iszkody.lsn.io/service/internal/ClaimService">
   <soapenv:Header/>
   <soapenv:Body>
      <ns0:createClaimRequest>
         <claim>
            <InsClaimData VER="1">
               <PartnerList>
                  <Partner>
                     <RoleList>
                        <Role>UBEZP</Role>
                     </RoleList>
                     <BusinessPartner>
                        <partnerType>person</partnerType>
                        <personData>
                           <firstName>JANUSZ</firstName>
                           <lastName>KOWALSKI</lastName>
                           <PESEL>83248328432</PESEL>
                        </personData>
                        <identifiers>
                           <businessId>123</businessId>
                           <otherId></otherId>
                        </identifiers>
                     </BusinessPartner>
                  </Partner>
               </PartnerList>
            </InsClaimData>
         </claim>
      </ns0:createClaimRequest>
   </soapenv:Body>
</soapenv:Envelope>

它看起来不像有效负载或xpath有问题,但更像是介体没有实现自定义类型。

1 个答案:

答案 0 :(得分:3)

我刚刚在WSO2 ESB 4.9.0和4.8.1中测试了以下内容,并且在这两个版本中,以下代理确实有效(我使用businessId丰富了otherId):

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Test_XPath" transports="http" xmlns:avintis="http://www.avintis.com">
    <target faultSequence="faultSequence">
        <inSequence>
            <sequence key="initSequence" />
            <log level="full"></log>
            <log level="custom">
                <property expression="$body//businessId" name="xpath" />
            </log>
            <log level="custom">
                <property expression="$body//Partner/BusinessPartner/identifiers/businessId" name="xpath" />
            </log>
            <enrich>
                <source xpath="//businessId" />
                <target xpath="//otherId" />
            </enrich>
            <log level="full" />
        </inSequence>
    </target>
</proxy>

当您评论您现在使用*[local-name()='BusinessPartner']语法时,这指出命名空间存在问题。尝试使用BusinessParter元素的正确名称空间。