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 "Ruchith Udayanga Fernando (JIRA)" <ji...@apache.org> on 2006/12/19 15:11:21 UTC

[jira] Resolved: (AXIS2-1874) missing attribute prefixes when creating xml with SAAJ

     [ http://issues.apache.org/jira/browse/AXIS2-1874?page=all ]

Ruchith Udayanga Fernando resolved AXIS2-1874.
----------------------------------------------

    Fix Version/s: 1.1.1
                   nightly
       Resolution: Fixed

http://svn.apache.org/viewvc?view=rev&rev=488677
http://svn.apache.org/viewvc?view=rev&rev=488682

> 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.1
>            Reporter: Michael Haeusler
>         Assigned To: Ruchith Udayanga Fernando
>            Priority: Blocker
>             Fix For: 1.1.1, nightly
>
>         Attachments: 1874.patch
>
>
> 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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org