CY, Please add this as a bugzilla bug.
Thanks, dims --- Ng Chi Yuen <[EMAIL PROTECTED]> wrote: > Hello, > > I wonder whether this is a bug as attached in the simple program. > When I add an attribute with different namespace into an element (line > 23-24, line 30-31), the namespace prefix and URI of such an attribute is not > set at all in the final message serialization. I think line 22 and 29, which > explicitly add the namespace declaration, are not neccessary but it still > doesn't work. > > Also, I wonder why in line 16, namespace declaration for local > prefix has already been set in SOAP envelope. But such a declaration still > appears once for each element being added which seems to be unneccessary. > > Thanks a lot for the help! > > Regards, > CY > > ---------------------------------------------------------------------------- > Ng Chi Yuen, CY. [EMAIL PROTECTED] http://www.cecid.hku.hk/ > Technology Officer, > Centre for E-Commerce Infrastructure Development, > The University of Hong Kong > ---------------------------------------------------------------------------- > > import javax.xml.soap.*; > > public class BugReport { > > private static final String LOCAL_PREFIX = "cecid"; > > private static final String LOCAL_URI = "http://www.cecid.hku.hk/"; > > private static final String ANOTHER_PREFIX = "abc"; > > private static final String ANOTHER_URI = "http://www.csis.hku.hk/"; > > public static void main(String[] args) throws Exception { > SOAPMessage message = MessageFactory.newInstance().createMessage(); > SOAPEnvelope env = message.getSOAPPart().getEnvelope(); > env.addNamespaceDeclaration(LOCAL_PREFIX, LOCAL_URI); > env.addNamespaceDeclaration(ANOTHER_PREFIX, ANOTHER_URI); > > Name name = env.createName("BugReport", LOCAL_PREFIX, LOCAL_URI); > SOAPHeader header = env.getHeader(); > SOAPHeaderElement she = header.addHeaderElement(name); > she.addNamespaceDeclaration(ANOTHER_PREFIX, ANOTHER_URI); > name = env.createName("def", ANOTHER_PREFIX, ANOTHER_URI); > she.addAttribute(name, "ghi"); > > SOAPBody body = env.getBody(); > name = env.createName("BugReport", LOCAL_PREFIX, LOCAL_URI); > SOAPBodyElement sbe = body.addBodyElement(name); > sbe.addNamespaceDeclaration(ANOTHER_PREFIX, ANOTHER_URI); > name = env.createName("def", ANOTHER_PREFIX, ANOTHER_URI); > sbe.addAttribute(name, "ghi"); > > message.writeTo(System.out); > } > } > > ===== Davanum Srinivas - http://webservices.apache.org/~dims/ __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
