Extra SOAP element xmlns="" value after upgrading from WLS 10 MP1 when using createName method of SOAPEnvelope of WLS SAAJ (Doc ID 1280619.1)

Last updated on JUNE 09, 2016

Applies to:

Oracle Weblogic Server - Version: 10.0 and later   [Release: and later ]
Information in this document applies to any platform.

Symptoms

When Using the SAAJ API to create element or child element, if a namespace is not explicitly declared the default namespace is xmlns="" is getting appended.

Sample XML Output1:WLS 10.0 MP1
==============================
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas"><env:Header/>
<env:Body>
<Login/>
</env:Body>
</env:Envelope>



Sample XML Output2:WLS 10.0 MP2 , WLS 10.3 and above versions.
======================================================
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas><env:Header/>
<env:Body>
<Login xmlns=""/>
</env:Body>
</env:Envelope>




The above Output1 is the SOAP envelope resulted when using the WLS 10.0 MP1 with weblogic.jar in the classpath.

The above output2 is the SOAP envelope resulted when using the WLS 10.0 MP2 with weblogic.jar or WLS 10.3 and above versions

 The difference is just the xmlns="" on the Login element.


Below is the sample code
====================
import javax.xml.soap.*;
public class TestActuate {

public static void main (String[]argv) throws Exception {

SOAPMessage a_message = null;
SOAPFactory a_soapFactory = SOAPFactory.newInstance();
MessageFactory a_messageFactory = MessageFactory.newInstance();
a_message = a_messageFactory.createMessage();
SOAPEnvelope a_envelope = a_message.getSOAPPart().getEnvelope();
a_envelope.addNamespaceDeclaration("", "http://schemas");
SOAPHeader a_header = a_envelope.getHeader();
SOAPBody a_body = a_envelope.getBody();
Name a_bodyName = a_soapFactory.createName("Login");
//Name a_bodyName = a_soapFactory.createName("Login","","http://schmas");
SOAPBodyElement a_bodyElement = a_body.addBodyElement(a_bodyName);
a_message.writeTo(System.out);

}}
===================

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms