Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-2721

SoapEnvelope serialization generates incorrect attribute xmlns:ns1="" for elements

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.4
    • None
    • None

    Description

      I try to send an XML over httpServlet, I did the following:

      (1) My XML tring is like this:

      <?xml version="1.0" encoding = "UTF-8" ?>

      <ns1:Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:ns1="http://businessobjects.com/cleanse_in">
      <ns1:PROSPECT_NUMBER>100957355</ns1:PROSPECT_NUMBER>
      <ns1:PROSPECT_NAME>SIERRA GOLF FLYERS RRRRRR</ns1:PROSPECT_NAME>
      <ns1:PROSPECT_ADDRESS1>11549 W 59TH PL RRRRRRRRRRRRRRRR</ns1:PROSPECT_ADDRESS1>
      <ns1:PROSPECT_ADDRESS2>10</ns1:PROSPECT_ADDRESS2>
      </ns1:Test>

      (2) Create a document

      InputSource source = new InputSource( new StringReader( xmlString ) ) ;
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setIgnoringElementContentWhitespace(false);
      DocumentBuilder docBuilder = factory.newDocumentBuilder();
      return docBuilder.parse(source);

      (3) Create a soapEnvelope

      SOAPEnvelope soapEnvelope = new SOAPEnvelope();
      Element bodyElement = createDocument(soapBodyText).getDocumentElement();
      org.apache.axis.message.SOAPBodyElement messageElement = new org.apache.axis.message.SOAPBodyElement(bodyElement);
      soapEnvelope.addBodyElement((SOAPBodyElement)messageElement);

      (4) Serialize the soapEnvelope before write it to the httpServletResponse

      String response = soapEnvelope .toString();

      (5) I saw the bug, the response is like the following:

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:Test xmlns:ns1="http://businessobjects.com/cleanse_in" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <ns1:PROSPECT_NUMBER xmlns:ns1="">100957355</ns1:PROSPECT_NUMBER>
      <ns1:PROSPECT_NAME xmlns:ns1="">SIERRA GOLF FLYERS RRRRRR</ns1:PROSPECT_NAME>
      <ns1:PROSPECT_ADDRESS1 xmlns:ns1="">11549 W 59TH PL RRRRRRRRRRRRRRRR</ns1:PROSPECT_ADDRESS1>
      <ns1:PROSPECT_ADDRESS2 xmlns:ns1="">11</ns1:PROSPECT_ADDRESS2>
      </ns1:Test>
      </soapenv:Body></soapenv:Envelope>

      Notice that there is an empty namespace prefix generated: xmlns:ns1="". This makes the response invalid.

      Attachments

        Activity

          People

            Unassigned Unassigned
            fchou99 Frank Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: