Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-8313

AddNamespace should not override the element's namespace

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.13.3, 2.14.1
    • 2.13.4, 2.14.2, 2.15.0
    • camel-cxf
    • None
    • Unknown

    Description

      I am running a web service in Cxf PAYLOAD mode and in one of the use cases I need to convert the body into Node (Element) and I am doing that by cxfpayload.getBody().get(0)
      This makes the namespaces from nsMap to be copied on to the element. While doing so, if the nsMap contains a namespace prefix that is also part of the element's attribute, it is being overwritten in the addNamespace(Element element, Map<String, String> nsMap) method.
      But when same prefix in soap Envelope and body contains different namespace values, that makes the body (XML) invalid.
      Here is a sample soap request that contains same namespace prefix ns1 in soap:Envelope and soap:Body but contains different namespace values.

      <soapenv:Envelope 
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:ns="http://www.example.com/location/consumerfundbalances/1/" 
      xmlns:ns1="http://www.example.com/consumerfundbalances/retrievefundbalances/bi/1/">
      <soapenv:Body>
      <ns1:retrieveFundBalances 
      xmlns="http://www.example.com/consumerfundbalances/retrievefundbalances/bi/1/"
      xmlns:ns1="http://www.example.com/location/consumerfundbalances/1/">
      <retrieveFundBalances>
      <fundBalancesRequestIdentifier/>
      </retrieveFundBalances>
      </ns1:retrieveFundBalances>
      </soapenv:Body>
      </soapenv:Envelope>
      

      Now when I convert the payload into DOM Node, here is output XML namespace value for prefix ns1 is being replaced with the envelope.

      <ns1:retrieveFundBalances 
      xmlns:ns1="http://www.example.com/consumerfundbalances/retrievefundbalances/bi/1/" 
      xmlns="http://www.example.com/consumerfundbalances/retrievefundbalances/bi/1/" 
      xmlns:ns="http://www.example.com/location/consumerfundbalances/1/">
      <retrieveFundBalances>
      <fundBalancesRequestIdentifier/>
      </retrieveFundBalances>
      </ns1:retrieveFundBalances>
      

      Attachments

        Activity

          People

            njiang Willem Jiang
            njiang Willem Jiang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: