DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20650>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20650 Duplicate Namespace Declaration: Bug in Serialization. Summary: Duplicate Namespace Declaration: Bug in Serialization. Product: Axis Version: 1.1rc2 Platform: All OS/Version: Other Status: NEW Severity: Major Priority: Other Component: Serialization/Deserialization AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I am using javax.xml.soap implementation to create the soap elements. When i add a custom Namespace and keep adding the elements in that namespace, then the custom namespace declaration is repeated. public void testquick() throws Exception { MessageFactory msgfactory = MessageFactory.newInstance(); SOAPFactory factory = SOAPFactory.newInstance(); SOAPMessage outputmsg = msgfactory.createMessage(); SOAPBody bodyout = outputmsg.getSOAPPart().getEnvelope().getBody(); Name n = factory.createName("HelloWorld","env", "http://helloworld.com"); SOAPBodyElement entry = bodyout.addBodyElement(n); n = factory.createName("code","env", "http://helloworld.com"); SOAPElement element = factory.createElement(n); entry.addChildElement(element); if (outputmsg != null) { if (outputmsg.saveRequired()) { outputmsg.saveChanges(); } outputmsg.writeTo(System.out); } } Output is: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <env:HelloWorld xmlns:env="http://helloworld.com"> <env:code xmlns:env="http://helloworld.com"/> <-- see the Namespace declaration is repeated </env:HelloWorld> </soapenv:Body> Ideal Output is <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <env:HelloWorld xmlns:env="http://helloworld.com"> <env:code /> </env:HelloWorld> </soapenv:Body> I personally feel this is because of the following code in MessageElement public MessageElement(String localPart, String prefix, String namespace) { this.namespaceURI = namespace; this.name = localPart; this.prefix = prefix; addMapping(new Mapping(namespace, prefix)); <-- Adding prefix for each declaration without checking whether parent element is in same namespace. } Or <MessageElement> protected void outputImpl(SerializationContext context) throws Exception { if (elementRep != null) { boolean oldPretty = context.getPretty(); context.setPretty(false); context.writeDOMElement(elementRep); context.setPretty(oldPretty); return; } if (textRep != null) { boolean oldPretty = context.getPretty(); context.setPretty(false); context.writeSafeString(textRep.getData()); context.setPretty(oldPretty); return; } if (prefix != null) context.registerPrefixForURI(prefix, namespaceURI); if (namespaces != null) { for (Iterator i = namespaces.iterator(); i.hasNext();) { Mapping mapping = (Mapping) i.next(); context.registerPrefixForURI(mapping.getPrefix(), mapping.getNamespaceURI()); } } </MessageElement> context.registerPrefixForURI should check for if prefix or URI is already present. Note : Please suggest a solution (If any) using only javax.xml.soap interfaces. I want to keep the generic interfaces and not make direct calls to MessageElements.
