NAMESPACE_ERROR when attempting to add xmlns:foo="bar" attribute in Java SOAP message

Solution Verified - Updated -

Issue

When migrating from JBoss EAP 4 to EAP 5, the following code no longer works, throwing an exception with NAMESPACE_ERROR.

MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
Name envelopeAttrib = sf.createName("xmlns:proc");
envelope.addAttribute(envelopeAttrib, "http://example.com/proc");

Environment

  • JBoss Enterprise Application Platform (EAP) 5.0

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.