You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John Hite <jh...@appsecinc.com> on 2008/09/23 16:51:09 UTC

RE: Using document/literal and rpc/encoded in same web service

Thanks for everyone's help on this. I've run into yet another problem. The
in interceptor works just fine for me, but I had problems trying to figure
out how to modify the contents of an OutputStream for the out interceptor. I
looked at your logging interceptor and found that you used a
CacheAndWriteOutputStream. I tried using this in my out interceptor. I
registered a CachedOutputStreamCallback that handles the transformation in
the onClose method. The problem I have is that when I call
message.setContent() and pass it an output stream with my modified message,
it is not used. I'm assuming that I'm using the CacheAndWriteOutputStream
incorrectly. Do you have any suggestions on how I should be transforming the
contents of the OutputStream?

Thanks,
John

-----Original Message-----
From: users-return-10172-jhite=appsecinc.com@cxf.apache.org
[mailto:users-return-10172-jhite=appsecinc.com@cxf.apache.org] On Behalf Of
Daniel Kulp
Sent: Monday, August 25, 2008 4:47 PM
To: users@cxf.apache.org
Cc: John Hite
Subject: Re: Using document/literal and rpc/encoded in same web service


>From the message, you can get the Exchange and from that, you can get the 
BindingOperationInfo  (exchange.get(BindingOperationInfo.class)).   From 
that, you can query the out message and from there the parts for that 
message.   In those parts should be the qnames and schema types and such.

Dan


On Monday 25 August 2008 3:51:27 pm John Hite wrote:
> Thanks, that helps a lot. I'm now stuck with a different problem.
> RPC/Encoded style messages require the types to be specified for
parameters
> and return values. Is there some way of finding the return parameter type
> information from the Message object?
>
> Thanks,
> John
>
> -----Original Message-----
> From: users-return-10128-jhite=appsecinc.com@cxf.apache.org
> [mailto:users-return-10128-jhite=appsecinc.com@cxf.apache.org] On Behalf
Of
> Ian Roberts
> Sent: Wednesday, August 20, 2008 7:08 PM
> To: users@cxf.apache.org
> Subject: Re: Using document/literal and rpc/encoded in same web service
>
> John Hite wrote:
> > 2) is there some way of marking the
> > messages on the way in so I know which messages need to be translated on
> > their way out?
>
> The in and out messages share the same Exchange object, so in your "in"
> interceptor, something like:
>
> message.getExchange().put("shouldUseRpcEncoded", Boolean.TRUE);
>
> and in your "out" interceptor:
>
> if(Boolean.TRUE.equals(message.getExchange().get("shouldUseRpcEncoded")))
{
>   ...
> }
>
> Ian



-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog



Re: Using document/literal and rpc/encoded in same web service

Posted by Daniel Kulp <dk...@apache.org>.
CacheAndWriteOutputStream is not what you want in this case.   Anything 
written to that stream gets "forked" and written into two places: the 
original socket and the cache.   Thus, by the time onClose is called, the 
client has the original request.  For logging, this works perfectly as it 
doesn't modify bytes.   Thus, the data can still be streamed to the client.

What you WANT to do is in your interceptor, grab the original OutputStream and 
store it someplace.   Replace it with a "new CachedOutputStream()".  In it's 
onClose handler, have it do the modification and call 
writeCacheTo(origOutput).    

That said, for this, mucking with the bytes might not be the best performing 
option.   I'd almost suggest configuring in the SAAJInInterceptor and before 
it's ending interceptor, modify the saaj object model.   That would avoid you 
having to re-parse the xml stream, you'd already have the DOM.

Dan



On Tuesday 23 September 2008 10:51:09 am John Hite wrote:
> Thanks for everyone's help on this. I've run into yet another problem. The
> in interceptor works just fine for me, but I had problems trying to figure
> out how to modify the contents of an OutputStream for the out interceptor.
> I looked at your logging interceptor and found that you used a
> CacheAndWriteOutputStream. I tried using this in my out interceptor. I
> registered a CachedOutputStreamCallback that handles the transformation in
> the onClose method. The problem I have is that when I call
> message.setContent() and pass it an output stream with my modified message,
> it is not used. I'm assuming that I'm using the CacheAndWriteOutputStream
> incorrectly. Do you have any suggestions on how I should be transforming
> the contents of the OutputStream?
>
> Thanks,
> John
>
> -----Original Message-----
> From: users-return-10172-jhite=appsecinc.com@cxf.apache.org
> [mailto:users-return-10172-jhite=appsecinc.com@cxf.apache.org] On Behalf Of
> Daniel Kulp
> Sent: Monday, August 25, 2008 4:47 PM
> To: users@cxf.apache.org
> Cc: John Hite
> Subject: Re: Using document/literal and rpc/encoded in same web service
>
>
> From the message, you can get the Exchange and from that, you can get the
> BindingOperationInfo  (exchange.get(BindingOperationInfo.class)).   From
> that, you can query the out message and from there the parts for that
> message.   In those parts should be the qnames and schema types and such.
>
> Dan
>
> On Monday 25 August 2008 3:51:27 pm John Hite wrote:
> > Thanks, that helps a lot. I'm now stuck with a different problem.
> > RPC/Encoded style messages require the types to be specified for
>
> parameters
>
> > and return values. Is there some way of finding the return parameter type
> > information from the Message object?
> >
> > Thanks,
> > John
> >
> > -----Original Message-----
> > From: users-return-10128-jhite=appsecinc.com@cxf.apache.org
> > [mailto:users-return-10128-jhite=appsecinc.com@cxf.apache.org] On Behalf
>
> Of
>
> > Ian Roberts
> > Sent: Wednesday, August 20, 2008 7:08 PM
> > To: users@cxf.apache.org
> > Subject: Re: Using document/literal and rpc/encoded in same web service
> >
> > John Hite wrote:
> > > 2) is there some way of marking the
> > > messages on the way in so I know which messages need to be translated
> > > on their way out?
> >
> > The in and out messages share the same Exchange object, so in your "in"
> > interceptor, something like:
> >
> > message.getExchange().put("shouldUseRpcEncoded", Boolean.TRUE);
> >
> > and in your "out" interceptor:
> >
> > if(Boolean.TRUE.equals(message.getExchange().get("shouldUseRpcEncoded")))
>
> {
>
> >   ...
> > }
> >
> > Ian



-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog