Hi Xinjun,
Thanks for pointing this out.
Changing the createElementInSameNamespace() method as follows should
fix this issue when the parent element has a default namespace:
private static Element createElementInSameNamespace(Element parent,
String localName) {
String qName = localName;
String prefix = parent.getPrefix();
if (prefix != null || prefix.length() > 0) {
qName = prefix + ":" + localName;
}
String nsUri = parent.getNamespaceURI();
return parent.getOwnerDocument().createElementNS(nsUri, qName);
}
I just checked in this fix to the latest svn can you please try it out.
Thanks,
Rcuhith
On 9/12/06, Xinjun Chen <[EMAIL PROTECTED]> wrote:
Further info:
When I debug, the following line:
String prefix = parent.getPrefix();
in WSSecurityUtil.createElementInSameNamespace(Element, String), it
gives unexpected result. I inspect the parent, it is correct. It is
"soap:Envelope" element. However, the prefix returned is "" while
"soap" is expected.
I tried to test the getPrefix() and getNamespaceUri() methods using
some test classes. I found that even if the SOAP Envelope contains
default namespace, getNamespaceUri() still returns null.
How does WSS4J test that? Is there anything I missed out?
Regards,
Xinjun
On 9/12/06, Xinjun Chen <[EMAIL PROTECTED]> wrote:
> I am trying to use wss4j 1.5 to test signature using UsernameToken.
> The SOAP message is to be processed by a .NET web service. I meet some
> error I don't know this is because of the namespace of the
>
>
> org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create
> or change an object in a way which is incorrect with regard to
> namespaces.
> at org.apache.xerces.dom.CoreDocumentImpl.checkNamespaceWF(Unknown
Source)
> at org.apache.xerces.dom.ElementNSImpl.setName(Unknown Source)
> at org.apache.xerces.dom.ElementNSImpl.<init>(Unknown Source)
> at org.apache.xerces.dom.CoreDocumentImpl.createElementNS(Unknown
Source)
> at
org.apache.ws.security.util.WSSecurityUtil.createElementInSameNamespace(WSSecurityUtil.java:519)
> at
org.apache.ws.security.util.WSSecurityUtil.findWsseSecurityHeaderBlock(WSSecurityUtil.java:637)
> at
org.apache.ws.security.message.WSSecHeader.insertSecurityHeader(WSSecHeader.java:134)
> at
tests.com.crimsonlogic.wsg.core.ws.security.TestSignature.main(TestSignature.java:194)
> Exception in thread "main"
>
>
> The original Soap Envelope is as follows:
>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
>
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
>
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
> <soap:Header>
> <wsa:Action wsu:Id="Id-79eb36bd-d85a-4b5e-929f-f3b193247bb2">
> http://tempuri.org/ProcessMessage
> </wsa:Action>
> <wsa:MessageID
> wsu:Id="Id-ca3138aa-9c1e-46dc-b7f2-982676fda931">
> uuid:9a8468bd-aa14-46a7-9090-5f37cd105151
> </wsa:MessageID>
> <wsa:ReplyTo wsu:Id="Id-1a1a632e-36c0-44ee-8794-e7a367c8ebbd">
> <wsa:Address>
>
http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous
> </wsa:Address>
> </wsa:ReplyTo>
> <wsa:To wsu:Id="Id-a71c4ecd-b73e-4d04-aab9-75c966122ff0">
> https://secureserver.com/wscomm.asmx
> </wsa:To>
> </soap:Header>
>
>
> Is this a bug of WSS4J 1.5? Could you suggest how to solve this problem?
>
>
>
> Regards,
> Xinjun
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
www.ruchith.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]