On Wednesday 17 November 2010 10:23:06 am Marian Muller wrote:
> Hello again,
>
> I would like some help with a client-side inbound interceptor. I am trying,
> within an interceptor at phase PRE_PROTOCOL, to replace the received
> response with a forged one. The forged response is a standard SOAPMessage.
>
> I tried replacing the InMessage in the exchange, but it does not seem to
> work: the former response is used instead of the forged one.
This is close, I think. You probably need:
responseMsg.setInterceptorChain(chain);
chain.reset(); //reset the iterator
chain.doIntercept(responseMsg);
// no need for this - chain.getInterceptorChain().abort();
That said, you'll probably need to setup a LOT more things for the message.
It will likely need an InputStream (not a SOAPMessage), a set of
PROTOCOL_HEADER things for the headers, etc...
Dan
>
>
> SOAPMessage response = // get the forged response somewhere
>
> //this.currentMessage.getInterceptorChain().abort();
> Endpoint e =
> this.currentMessage.getExchange().get(Endpoint.class);
> if (!this.currentMessage.getExchange().isOneWay()) {
> Message responseMsg = new MessageImpl();
> responseMsg.setExchange(this.currentMessage.getExchange());
> responseMsg = e.getBinding().createMessage(responseMsg);
>
> this.currentMessage.getExchange().setInMessage(responseMsg);
>
> responseMsg.setContent(SOAPMessage.class, response);
>
> InterceptorChain chain = /*OutgoingChainInterceptor
>
> .getOutInterceptorChain(this.currentMessage.getExchange());*/
> this.currentMessage.getInterceptorChain();
> responseMsg.setInterceptorChain(chain);
> /*chain.doInterceptStartingAfter(responseMsg,
> SoapPreProtocolOutInterceptor.class.getName());*/
> logger.error("doIntercept() ON THE NEW RESPONSE");
> chain.doIntercept(responseMsg);
> logger.error("ABORT INTERCEPTION OF THE OLD RESPONSE");
> this.currentMessage.getInterceptorChain().abort();
> logger.error("ENDING...");
> }
>
>
> Thank you for your help.
> --
> Marian MULLER
> SERLI
--
Daniel Kulp
[email protected]
http://dankulp.com/blog