2 Replies Latest reply: Oct 7, 2010 1:03 AM by 544143 RSS

    How to remove namespace in BPEL

    781450
      I wrote a custom java web service which accepts xml string and I am using this WSDL in my BPEL.

      How do I remove the name spaces in xml before sending to external system.

      <ImportOrder xmlns:client="http://xmlns.oracle.com/............BPEL"
      xmlns=" ............. BPEL">
      <client:OrderList>
      <client:Order>
      <client:Number>1234</client:Number>
      .....
      .....
      </client:Order>
      </client:OrderList>
      </ImportOrder>

      Thanks

      Edited by: soauser on Aug 31, 2010 6:35 PM

      Edited by: soauser on Aug 31, 2010 6:35 PM
        • 1. Re: How to remove namespace in BPEL
          Amirineni23
          Removing name spaces from your XML payload is sometimes needed. This post shows you how to remove namesapces in your XML payload.

          XML Stylesheets (XSLT)

          For BPEL and ESB you can use the XSLT solution to remove namespaces. The below example show you how to implement this in BPEL. First we need to create a XSLT file. The file should looks like this:

          RemovingNamespace.xsl
          <?xml version="1.0" encoding="UTF-8" ?>
          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          exclude-result-prefixes="xsl">
          <xsl:template match="comment()|processing-instruction()|/">
          <xsl:copy>
          <xsl:apply-templates/>
          </xsl:copy>
          </xsl:template>
          <xsl:template match="*">
          <xsl:element name="{local-name()}">
          <xsl:apply-templates select="@*|node()"/>
          </xsl:element>
          </xsl:template>
          <xsl:template match="@*">
          <xsl:choose>
          <xsl:when test="name() != 'xmlns'">
          <xsl:attribute name="{local-name()}">
          <xsl:value-of select="."/>
          </xsl:attribute>
          </xsl:when>
          </xsl:choose>
          </xsl:template>
          </xsl:stylesheet>
          The BPEL code to call this XSLT is as follows.

          <assign name="'RemoveNamespace ">
          <copy>
          <from expression="ora:getContentAsString(
          ora:processXSLT('RemovingNamespace.xsl'
          , bpws:getVariableData('inputVariable','payload'))
          )"/>
          <to variable="outputVariable" part="payload"
          query="/client:BPELNameSpaceRemoverProcessResponse/client:result"/>
          </copy>
          </assign>


          Thanks,
          Sagar.
          • 2. Re: How to remove namespace in BPEL
            544143
            Hi Sagar,

            I tried the xslt. It works fine for an xml without any attributes. But if the input xml has attributes it fails.

            Sample xml
            <TestXML xmlns="http://xmlns.oracle.com/TestRemoveNamespace" testattr="data">
            <General>
            <Column1>Col1</Column1>
            </General>
            <Data>
            <DataRow1>
            <Col1>123</Col1>
            <Col2>1234</Col2>
            <Col3>Normal</Col3>
            </DataRow1>
            <DataRow2>
            <Col1>123</Col1>
            <Col2>1234</Col2>
            <Col3>Normal</Col3>
            </DataRow2>
            </Data>
            </TestXML>

            If I remove the testattr attribute from the xml, the xslt works fine.

            Any ideas?

            Your input is highly appreciated.

            Thanks,
            Gayathri