DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Why dp:url-open is adding additional namespace automatically?

    Posted Thu April 10, 2025 05:20 AM
    Edited by Mahender Batta Thu April 10, 2025 09:19 AM

    Dear All,

    I'm encountering an issue with the addition namespaces were added to my input XML message in the dp:url-open. 
    Here in my sample input message

     <Message>                           
          <Name>Jhon</Name>
          <Date>2025-03-09T11:54:03</Date>                      
    </Message>
    
     <xsl:variable name="response">
           <dp:url-open target="{$url}" response="responsecode" content-type="text/xml" http-method="POST" http-headers="$httpHeaders">
                 <xsl:copy-of select="$inputXML"/>
          </dp:url-open>
     </xsl:variable>

    but dp:url-open is posting message to the backend as below:

    Here it is adding following namespaces to the request xmlns:dp="http://www.datapower.com/schemas/management" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx". Due to these namespaces backend server is refusing the message.

     <Message xmlns:dp="http://www.datapower.com/schemas/management" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
                      xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">                           
          <Name>Jhon</Name>
          <Date>2025-03-09T11:54:03</Date>                      
    </Message>
    

    Is there a way to stop adding these namespaces to the request in dp:url-open?

    Thanks!



    ------------------------------
    Mahender Batta
    ------------------------------



  • 2.  RE: Why dp:url-open is adding additional namespace automatically?

    Posted Thu April 10, 2025 09:05 AM

    Have you attempted to put 'exclude-result-prefixes="dp env json"' in your stylesheet element declaration?



    ------------------------------
    Joseph Morgan
    CEO - Independent
    ------------------------------



  • 3.  RE: Why dp:url-open is adding additional namespace automatically?

    Posted Thu April 10, 2025 09:19 AM

    Yes, @Joseph Morgan, I have already added it.

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx" xmlns:str="http://exslt.org/strings" extension-element-prefixes="dp str" exclude-result-prefixes="dp json env str" version="1.0"> </xsl:stylesheet>



    ------------------------------
    Mahender Batta
    ------------------------------



  • 4.  RE: Why dp:url-open is adding additional namespace automatically?

    Posted Thu April 10, 2025 09:32 AM

    Interesting.  So, I found this XSLT in my box-of-tricks for DataPower.  I know I haven't used this in a long while, but there must be a reason I wrote it.  You may have to make a few changes to your process to generate the message and send it via a Results action (like I said, I forgot why I wrote it...), but, this little transform removes namespaces from an XML message:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
      
     <!-- keep comments -->
     <xsl:template match="comment()">
        <xsl:copy>
          <xsl:apply-templates/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="*">
        <!-- remove element prefix -->
        <xsl:element name="{local-name()}">
          <!-- process attributes -->
          <xsl:for-each select="@*">
            <!-- remove attribute prefix -->
            <xsl:attribute name="{local-name()}">
              <xsl:value-of select="."/>
            </xsl:attribute>
          </xsl:for-each>
          <xsl:apply-templates/>
        </xsl:element>
      </xsl:template>
    </xsl:stylesheet>
    


    ------------------------------
    Joseph Morgan
    CEO - Independent
    ------------------------------



  • 5.  RE: Why dp:url-open is adding additional namespace automatically?

    Posted Thu April 10, 2025 09:41 AM

    Thank you @Joseph Morgan for the suggestion. 
    How can I intercept request body with in the url-open? In my original message does not contains namespaces.



    ------------------------------
    Mahender Batta
    ------------------------------



  • 6.  RE: Why dp:url-open is adding additional namespace automatically?

    Posted Thu April 10, 2025 04:00 PM

    Sorry, I should have been more clear.   You'd have to stop using the dp:url-open.

    Build the message without the explicit name-spacing in some kind of transform (I suspect that's what you're doing).   Then send that to the back end.   With that, I don't think DataPower would modify it further.   If it does, you may have to use something like my little trick above.  But, I think if you just build the message with a transform as the last thing on the processing rule, you should be OK.

    Client to Server rule:    INPUT -> other actions -> transform to build message (nothing else)



    ------------------------------
    Joseph Morgan
    CEO - Independent
    ------------------------------