missing attribute prefixes when creating xml with SAAJ
------------------------------------------------------
Key: AXIS2-1874
URL: http://issues.apache.org/jira/browse/AXIS2-1874
Project: Apache Axis 2.0 (Axis2)
Issue Type: Bug
Components: modules
Affects Versions: 1.1
Reporter: Michael Haeusler
Priority: Blocker
here is some test code that creates invalid XML:
MessageFactory fac = MessageFactory.newInstance();
SOAPMessage msg = fac.createMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPHeader header = msg.getSOAPHeader();
Name name = env.createName("Local","pre1", "http://test1");
SOAPElement local = header.addChildElement(name);
Name name2 = env.createName("Local1","pre1", "http://test1");
SOAPElement local2 = local.addChildElement(name2);
Name aName = env.createName("attrib","pre1", "http://test1");
local2.addAttribute(aName, "value");
msg.writeTo(System.out);
the output is this (formatted for better readability):
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<pre1:Local xmlns:pre1="http://test1">
<pre1:Local1 xmlns="http://test1" attrib="value" />
</pre1:Local>
</soapenv:Header>
<soapenv:Body />
</soapenv:Envelope>
there are two things incorrect in this output.
- there is a default namespace defined on element "Local1" which is unwanted.
- the attribute "attrib" does not have a prefix as it should have, an xml
validation against a schema will fail due to this
I found the reason for this behavior after some debugging.
org.apache.axis2.saaj.SOAPElementImpl contains a bug in
public SOAPElement addChildElement(String localName, String prefix) throws
SOAPException
in this method
createElementNS(namespaceURI, localName)
is called and that is wrong, because this method expects a qualified name not
a local name.
I did a quick test with changing it to
createElementNS(namespaceURI, prefix + ":" + localName)
and that solved both problems.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]