Friday 8 February 2019

FONS0004: no namespace found for prefix

Are you seeing the below exception stack while executing the countNodes() function,

FONS0004: no namespace found for prefix...
        at oracle.xml.xpath.JXPathExpression.evaluate(JXPathExpression.java:269)
        at oracle.xml.xpath.JXPath.evaluate(JXPath.java:383)
        at com.collaxa.cube.xml.xpath.BPELXPathUtil.selectNodes(BPELXPathUtil.java:533)
        at com.collaxa.cube.xml.xpath.BPELXPathUtil.selectNodes(BPELXPathUtil.java:517)
        at com.collaxa.cube.xml.xpath.functions.xml.CountNodesFunction.evaluate(CountNodesFunction.java:143)
        at com.collaxa.cube.xml.xpath.functions.xml.CountNodesFunction.call(CountNodesFunction.java:78)
        at com.collaxa.cube.xml.xpath.BPELXPathFunctionWrapper.evaluate(BPELXPathFunctionWrapper.java:80)
        at oracle.xml.xpath.JXPathContext$JXFunction.invoke(JXPathContext.java:213)
        at oracle.xml.xpath.JXPathContext$JXFunction.invoke(JXPathContext.java:182)
        at oracle.xml.xpath.XPathExtFunction.evaluate(XPathExtFunction.java:335)

Then you need to check whether you are using the namespace defined in the root element for your xsi:type extension usage,

eg;

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/cloud/adapter/erp/FindItem_REQUEST/types" xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/">
   <soapenv:Body>
      <typ:findItem>
         <typ:findCriteria xsi:type="typ1:ChildFindCriteria" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <typ1:fetchStart>10</typ1:fetchStart>
         </typ:findCriteria>
      </typ:findItem>
   </soapenv:Body>
</soapenv:Envelope>

Instead, add another namespace definition in <findCriteria>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/cloud/adapter/erp/FindItem_REQUEST/types" xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/">
   <soapenv:Body>
      <typ:findItem>
         <typ:findCriteria xsi:type="typ3:ChildFindCriteria" xmlns:typ3="http://xmlns.oracle.com/adf/svc/types/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <typ1:fetchStart>10</typ1:fetchStart>
         </typ:findCriteria>
      </typ:findItem>
   </soapenv:Body>
</soapenv:Envelope>