Integration

Get Involved. Join the Conversation.

Topic

    Mark Chappell
    XPATH Filter Expression
    Topic posted May 30, 2019 by Mark ChappellBronze Medal: 1,250+ Points, tagged Adapters, Events, Integration, xml 
    116 Views, 10 Comments
    Title:
    XPATH Filter Expression
    Summary:
    How to define the XPATH Filter Expression in the ERP Adapter
    Content:

    Hi Forum Members

    I'm trying to construct the xpath expression in order that I can filter on a particular value in the payload receive, when I'm subscribing to a particular even in Oracle Product Hub.

    I am having trouble with this.

    Does anyone have any experience in how we to build up the correct expression and the syntax to use? 

    The payload that I can see when running my integration, and I blindly subscribe to my ERP Adapter event, is show below;

    <ns01:onEvent 
    xmlns:ns01="http://xmlns.oracle.com/cloud/adapter/erp/getGTIN_REQUEST/types">   <ns0:findItemResponse xmlns="" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://xmlns.oracle.com/cloud/adapter/erp/getGTIN_REQUEST/types" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">      <ns0:result xmlns:ns0="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/" 
    xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:ns10="http://xmlns.oracle.com/apps/scm/productModel/items/flex/itemGdf/" xmlns:ns6="http://xmlns.oracle.com/apps/scm/productCatalogManagement/advancedItems/flex/egoItemEff/item/categories/" xmlns:ns9="http://xmlns.oracle.com/apps/scm/productModel/items/flex/item/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:Item">         <ns1:ItemId>100000001454061</ns1:ItemId>         <ns1:OrganizationId>300000001809988</ns1:OrganizationId>         <ns1:OrganizationCode>BURYWH01</ns1:OrganizationCode>   

     

    I need to filter on the value <ns1:OrganizationCode>BURYWH01</ns1:OrganizationCode>, so the Integration will only process if the OrganisationCode is BURYWH01.

     

    I have tried the following as the XPATH expression, but it is not working... the Integration accepts this as a valid XPATH Expression, but when my item is updated, my Integration is NOT triggered, 

    <xpathExpr xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" >$eventPayload/ns01:onEvent/ns1:OrganizationCode="BURYWH01"</xpathExpr>

    I have cloned this integration, removed the xpath expression and activated. When my item is updated, this Integration is triggered.

    any help with this is greatly appreciated.

    thank you

    Mark

    Image:

    Comment

     

    • Niraj Hegdekar

      Hi Mark,

      I noticed in your xpath expression you have declared ns1, but you did not declare ns01.

      You may want to try:

      <xpathExpr xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:ns01='http://xmlns.oracle.com/cloud/adapter/erp/getGTIN_REQUEST/types' >$eventPayload/ns01:onEvent/ns1:OrganizationCode="BURYWH01"</xpathExpr>

    • Monish Munot

      Use following expression in the filter,

      <xpathExpr xmlns:ns01="http://xmlns.oracle.com/cloud/adapter/erp/getGTIN_REQUEST/types" xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/">$eventPayload/ns01:onEvent/ns1:OrganizationCode="BURYWH01"</xpathExpr>

      You can refer this.

    • Mark Chappell

      Thanks Guys for your comments - both suggestions are the same combination of namespaces in the xpath expression - but both fail in OICS - please see my attached screen shot.

      Does this imply, that I need to include other namespaces in the Xpath Expression? i.e. from those that I see in the payload when running my integration, and I blindly subscribe to my ERP Adapter event, is show below;

      <ns01:onEvent 
      xmlns:ns01="http://xmlns.oracle.com/cloud/adapter/erp/getGTIN_REQUEST/types">   <ns0:findItemResponse xmlns="" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://xmlns.oracle.com/cloud/adapter/erp/getGTIN_REQUEST/types" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">      <ns0:result xmlns:ns0="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/" 
      xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:ns10="http://xmlns.oracle.com/apps/scm/productModel/items/flex/itemGdf/" xmlns:ns6="http://xmlns.oracle.com/apps/scm/productCatalogManagement/advancedItems/flex/egoItemEff/item/categories/" xmlns:ns9="http://xmlns.oracle.com/apps/scm/productModel/items/flex/item/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:Item">         <ns1:ItemId>100000001454061</ns1:ItemId>         <ns1:OrganizationId>300000001809988</ns1:OrganizationId>         <ns1:OrganizationCode>BURYWH01</ns1:OrganizationCode>   

       

      again, your help is greatly appreciated.

       

      thanks 

      Mark

    • Kanchankumar Khedkar

      Hello Mark,

      I used condition as below, and It worked for me. smileyJust now. Please check below condition and see if it works for you as well. 

      <xpathExpr xmlns:ns_0="http://xmlns.oracle.com/adf/svc/types/" xmlns:ns_1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:ns_2="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/">$eventPayload/ns_2:result/ns_0:Value/ns_1:OrganizationCode="BURYWH01"</xpathExpr>

      ERP Cloud - 19a

      OIC - Version: 19.2.1.0.0

      Regards,

      KK

      • Kanchankumar Khedkar

        more over if you are wondering why element value is coming into picture - my guess -

        Oracle SaaS Captures business event and then based on id it does findItem to fetch the items details, it is on this findItem Response, filter specified in filter condition is applied. This is based on eventCatalog 

        {"documentService":{"outputXPath":null,"inputXSLT":"oramds:/oracle/apps/scm/productModel/items/findItemFromItemBE.xsl","keyMaps":[],"csfkey":null,"wsdlInterface":"http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/#wsdl.interface(ItemService)","wsdlLocation":"${ORA_FSCM_SERVICESAPPProtocolToken}://${ORA_FSCM_SERVICESAPPHostToken}:${ORA_FSCM_SERVICESAPPPortToken}/fscmService/ItemServiceV2?WSDL","wsdlPort":"http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/#wsdl.endpoint(ItemService/ItemServiceSoapHttpPort)","operation":"findItem"},"documentTransform":null,"customEvents":[],"name":"{/oracle/apps/scm/productModel/items/protectedModel/entity/events/edl/ItemEO}postItemUpdate","id":"SCM_EGP_ITEM_UPDATE","displayName":"Item Update Event","description":"This public event signals an item is updated"}

        And findItemResponse have structure as  findItemResponse/results/Value/ItemAttributes*. This is why value in XPATH is required. 

        Sample find item response.

         <ns0:findItemResponse xmlns:ns0="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/">
                 <ns2:result xsi:type="ns0:DataObjectResult" xmlns:ns2="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/" xmlns:ns1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:tns="http://xmlns.oracle.com/adf/svc/errors/" xmlns:ns0="http://xmlns.oracle.com/adf/svc/types/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <ns0:Value xsi:type="ns1:Item" xmlns:ns6="http://xmlns.oracle.com/apps/scm/productCatalogManagement/advancedItems/flex/egoItemEff/item/categories/" xmlns:ns7="http://xmlns.oracle.com/apps/scm/productModel/items/flex/item/" xmlns:ns8="http://xmlns.oracle.com/apps/scm/productModel/items/flex/itemGdf/">
                       <ns1:OrganizationCode>ORG_CODE</ns1:OrganizationCode>

    • Mark Chappell

      Hi Guys

      thanks for your help in this issue! I have now managed to add the correct XPATH expression.

      Monish's suggested LINK talks specifically and luckily about the very business event I am subscribing too, so gave me the exact expression to use, as well as a good explanation of why - so I have a much better understanding now of how to construct futher xpath expressions.

      a great article, thank you Monish for sharing: http://www.ateam-oracle.com/using-business-events-in-fusion-based-saas-part-3-event-filter-expressions#respond

      My expression:

      <xpathExpr xmlns:ns_0="http://xmlns.oracle.com/adf/svc/types/" xmlns:ns_1="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/" xmlns:ns_2="http://xmlns.oracle.com/apps/scm/productModel/items/itemServiceV2/types/">$eventPayload/ns_2:result/ns_0:Value/ns_1:OrganizationCode="BURYWH01"</xpathExpr> 

       

      thank you all again for your help :)

      Mark