On Monday, September 19, 2011 4:15:40 PM Максим Мартынов wrote:
> Error "Cannot Replace the To Soap Header" was because 2 Soap Envelop write
> in request.
> But i can't to replace outgoing stream.
> Can anybody help?

With the way CXF streams data onto the wire, replacing the contents of the 
stream is a bit more difficult.   It's really a two part thing:

1) You would need one interceptor that lives very early in the chain that 
would grab the current OutputStream and saves it (likely on a unique key on 
the Message) for retrieval later.   Then replace it with a new 
ByteArrayOutputStream or similar (FileOutputStream, CachedOutputStream, 
etc...).    CXF would then use that for writing anything it produces.


2) A SECOND  interceptor on the chain (late in the chain) that would grab the 
bytes from that replaces stream, manipulate it, produce new bytes, and then 
write that to the original output stream and then put the output stream back 
on the message.

Dan



> 19 сентября 2011 г. 9:49 пользователь Максим Мартынов
> 
> <[email protected]>написал:
> > I try to process OutputStream at Phase.PRE_STREAM_ENDING phase but now i
> > can get error "javax.xml.ws.soap.SOAPFaultException: Cannot Replace the
> > To Soap Header"
> > 
> > My code is:
> >  OutputStream os = message.getContent(OutputStream.class);
> > 
> > CacheAndWriteOutputStream cos = (CacheAndWriteOutputStream) os;
> > 
> > byte[] security = cryptoService.createSmevHeaderSecurity(cos.getBytes(),
> > fingerprint);
> > ByteArrayInputStream bis = new ByteArrayInputStream(security);
> > 
> >  CachedOutputStream.copyStream(bis, os, 1024);
> > 
> > os.flush();
> > message.setContent(OutputStream.class, os);
> > 
> > 2011/9/16 Максим Мартынов <[email protected]>
> > 
> >> Hi. Please help.
> >> 
> >> How i can get outgoing message in outIntercepter as *byte[]*?
> >> Change it, and set it to original outgoing message?
> >> In which phase a can do that?
> >> 
> >> My task is to sign envelope, but service which can do this whant as
> >> incoming parameters soap envelop as byte[] and result is signing soap
> >> envelop, as byte[] too.
> >> 
> >> Please give me an example?
> >> *
> >> *
-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com

Reply via email to