JBossWS SAAJ omits default namespace declaration in SOAP element

Solution In Progress - Updated -

Issue

When invoking web services using the SAAJ API, the invocation is performed like this:

SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFactory.createConnection();
connection.call(message, destination);

However, when the message is marshalled to SOAP an error occurs. The message is constructed like this:

MessageFactory messageFactory = MessageFactory.newInstance();
message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPElement element = body.addChildElement(envelope.createName("getDocument", "", "http://webservice.redhat.com"));
SOAPElement systemInfo = element.addChildElement(envelope.createName("systemInfo", "", "http://webservice.redhat.colm"));
SOAPElement systemName = systemInfo.addChildElement("systemName", "", "http://redhat.com/xsd");
systemName.addTextNode("SDLon");
SOAPElement userName = systemInfo.addChildElement("userName", "", "http://redhat.com/xsd");
userName.addTextNode("username");

The anonymous namespace specified for the username element is omitted when producing the SOAP message. In the attached test case this is simply reproduced like this:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.writeTo(baos);
String envelopeAsString = new String(baos.toByteArray(), "utf-8");

If using a pretty print approach (Transformer) the namespace is attached to the message correctly. Furthermore removing all JBoss libraries from the project (i.e. use JDK SAAJ impl), the generated SOAP message is correct. Is this a bug? Are there any workarounds?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.x
    • JBossWS Native

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.