You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2003/07/24 15:48:47 UTC

DO NOT REPLY [Bug 21854] New: - Setting attribute with different namespace does not work

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21854>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21854

Setting attribute with different namespace does not work

           Summary: Setting attribute with different namespace does not work
           Product: Axis
           Version: 1.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: axis-dev@ws.apache.org
        ReportedBy: cyng@csis.hku.hk


Please refer to the following simple program to reproduce the bug.

    When an attribute with different namespace is added into an element (line
23-24, line 30-31), the namespace prefix and URI of such an attribute is not
set at all in the final message serialization. I think line 22 and 29, which
explicitly add the namespace declaration, are not neccessary but it still
doesn't work.

         Also, in line 16, namespace declaration for local prefix has already
been set in SOAP envelope. But such a declaration still appears once for each
element being added which seems to be unneccessary.

import javax.xml.soap.*;

public class BugReport {

    private static final String LOCAL_PREFIX = "cecid";

    private static final String LOCAL_URI = "http://www.cecid.hku.hk/";

    private static final String ANOTHER_PREFIX = "abc";

    private static final String ANOTHER_URI = "http://www.csis.hku.hk/";

    public static void main(String[] args) throws Exception {
        SOAPMessage message = MessageFactory.newInstance().createMessage();
        SOAPEnvelope env = message.getSOAPPart().getEnvelope();
        env.addNamespaceDeclaration(LOCAL_PREFIX, LOCAL_URI);
        env.addNamespaceDeclaration(ANOTHER_PREFIX, ANOTHER_URI);

        Name name = env.createName("BugReport", LOCAL_PREFIX, LOCAL_URI);
        SOAPHeader header = env.getHeader();
        SOAPHeaderElement she = header.addHeaderElement(name);
        she.addNamespaceDeclaration(ANOTHER_PREFIX, ANOTHER_URI);
        name = env.createName("def", ANOTHER_PREFIX, ANOTHER_URI);
        she.addAttribute(name, "ghi");

        SOAPBody body = env.getBody();
        name = env.createName("BugReport", LOCAL_PREFIX, LOCAL_URI);
        SOAPBodyElement sbe = body.addBodyElement(name);
        sbe.addNamespaceDeclaration(ANOTHER_PREFIX, ANOTHER_URI);
        name = env.createName("def", ANOTHER_PREFIX, ANOTHER_URI);
        sbe.addAttribute(name, "ghi");

        message.writeTo(System.out);
    }
}