If you modify the SAAJ stuff in an interceptor, you probably also need to
replace the XMLStreamReader that is wrappering the SAAJ model. Try doing:
DOMSource bodySource = new
DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
xmlReader = StaxUtils.createXMLStreamReader(bodySource);
xmlReader.nextTag();
xmlReader.nextTag(); // move past body tag
message.setContent(XMLStreamReader.class, xmlReader);
(not sure on the number of nextTag things in there)
Basically, internally, most things in CXF operate on the XMLStreamReader.
Thus, it has to be correct and pointing at the right elements. Most likely,
when your interceptor is running, it's pointing at the encrypted element and
you are replacing it with a non-encrypted element, but the reader is still
pointing at it.
Dan
On Thu July 9 2009 1:27:56 pm Kid_79 wrote:
> Hi all, I don't solve my error. Now I try to describe this my problem.
>
> A client calls a web service that it uses a my interceptor
> (RequestInterceptor); it gets SOAPMessage from SoapMessage of CXF and then
> it uses my task for encrypt/signature implemented with wss4j and this task
> returns a modify SOAPMessage; now in RequestInterceptor I set SOAPMessage
> into cxf SoapMessage.
> Now here it's ok, in TCP monitor I have an encrypt/signature Envelope.
> After RequestInterceptor, I call another web service that
> decrypt/signature; this web service uses an interceptor
> (RequestInterceptor) the same as the first (that it gets SOAPMessage, etcc
> and a task uses decrypt/signature) and then in RequestInterceptor I set
> SOAPMessage into cxf SoapMessage. The operation decrypt/signature are ok,
> wss4j works; but in this point I have an error, on DocLiteralInInterceptor
> interceptor.
>
> If I use in my task signature or usernameToken it's works, while when I use
> a encrypt I have an error.
> It seems when the body is changed!!
>
> I hope to be clear to describe the problem and that someone can help me.
>
> This is my error:
> org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Message part
> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized. (Does
> it exist in service WSDL?)
> at
> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral
>InInterceptor.java) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:236)
>
> dkulp wrote:
> > On Fri June 26 2009 1:23:49 pm Kid_79 wrote:
> >> Hi all,
> >> I'm using CXF 2.1.4 with my interceptor (my WSS4J).
> >> When I use action = Encrypt Signature UsernameToken I'have this error:
> >>
> >> org.apache.cxf.interceptor.Fault: Message part
> >> {http://www.w3.org/2001/04/xmlenc#}EncryptedData was not recognized.
> >> (Does
> >> it exist in service WSDL?)
> >>
> >> Can you help me?
> >
> > It sounds like your interceptor isn't properly decrypting everything.
> > That
> > element is left encrypted so we don't know what it is.
> >
> > --
> > Daniel Kulp
> > [email protected]
> > http://www.dankulp.com/blog
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog