Additional namespace definition is added to the SOAPEnvelope when loading an
existing soapmessage using SAAJ
------------------------------------------------------------------------------------------------------------
Key: AXIS2-517
URL: http://issues.apache.org/jira/browse/AXIS2-517
Project: Apache Axis 2.0 (Axis2)
Type: Bug
Components: om
Environment: Sun JDK 1.5.0_06
Reporter: Jörg Eichhorn
When loading a soap message which was created using a different namespace
prefix for the soapenvelope than Axis2 does, the namespace definition using the
'soapenv' prefix is added.
When loading the message using the MessageFactory it will internally create a
new instance of the class org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl by
using the constructor:
public SOAPEnvelopeImpl(DocumentImpl doc, OMXMLParserWrapper builder,
SOAPFactory factory)
In this constructor it calls the parent constructor with the new namespace
definition using the default prefix. When the to be loaded soap message uses a
different prefix, this will result into two xmlns definitions with the soap
envelope namespace url when writing the message out again.
A possible solution could be just don't create a the new namespace in the class
SOAPEnvelopeImpl and pass null to the parent constructor.
I tested with axis2 from svn trunk revision 388932.
Sample code:
import java.io.FileInputStream;
import java.io.InputStream;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
public class Test
{
public static void main(String[] args)
{
InputStream in = null;
try
{
in = new FileInputStream("minimalMessage.xml");
SOAPMessage msg = MessageFactory.newInstance().createMessage(null,
in);
msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
msg.writeTo(System.out);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try { in.close(); } catch (Exception e) { }
}
}
}
MinimalMessage:
<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body/>
</env:Envelope>
Output:
<?xml version='1.0' encoding='utf-8'?><env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body/>
</env:Envelope>
--
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