You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sandun Perera <sa...@gmail.com> on 2017/04/19 19:59:05 UTC

Username Token Validation Error

HI All

I'm working on a project which uses a CXF SoapMessage generated form a
string. I'm trying use Username Token Validation but it throws
*NullPointerException.
*This is the source code [1]
<https://gist.github.com/anonymous/bfb6f65194a030a50681af175a9937f5> I
used. I pass a SOAP message [2]
<https://gist.github.com/anonymous/f704db6147e02acdff323dc67ccff6d6> as a
string to *initiateComplianceCheck* method and it then convert it to a CXF
SoapMessage object and use it for Username Token authentication.

[1] https://gist.github.com/anonymous/bfb6f65194a030a50681af175a9937f5
[2] https://gist.github.com/anonymous/f704db6147e02acdff323dc67ccff6d6

But CXF handleMessage gives a NullPointerException

This is a part of the error message thrown

java.lang.NullPointerException
> at
> org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:165)


Appreciate if you can help me to solve this issue

Regards

Re: Username Token Validation Error

Posted by Colm O hEigeartaigh <co...@apache.org>.
The NPE is because there is no Message Exchange set on the SoapMessage.
I'll fix the NPE. In the meantime you could add in the following to your
code:

 Exchange ex = new ExchangeImpl();
 ex.setInMessage(message);

See for example:

https://github.com/apache/cxf/blob/3.1.x-fixes/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java

By the way, the wsse namespace you are using in the sample is from a very
old standard and won't work. It should be xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
instead.

Colm.

On Wed, Apr 19, 2017 at 8:59 PM, Sandun Perera <sa...@gmail.com>
wrote:

> HI All
>
> I'm working on a project which uses a CXF SoapMessage generated form a
> string. I'm trying use Username Token Validation but it throws
> *NullPointerException.
> *This is the source code [1]
> <https://gist.github.com/anonymous/bfb6f65194a030a50681af175a9937f5> I
> used. I pass a SOAP message [2]
> <https://gist.github.com/anonymous/f704db6147e02acdff323dc67ccff6d6> as a
> string to *initiateComplianceCheck* method and it then convert it to a CXF
> SoapMessage object and use it for Username Token authentication.
>
> [1] https://gist.github.com/anonymous/bfb6f65194a030a50681af175a9937f5
> [2] https://gist.github.com/anonymous/f704db6147e02acdff323dc67ccff6d6
>
> But CXF handleMessage gives a NullPointerException
>
> This is a part of the error message thrown
>
> java.lang.NullPointerException
> > at
> > org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(
> WSS4JInInterceptor.java:165)
>
>
> Appreciate if you can help me to solve this issue
>
> Regards
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com