Sorry, the mail was sent before i could clean the code extract:

            SOAPMessage response = // get the forged response

            // Create a new CXF message and link it to the exchange
            Endpoint e =
this.currentMessage.getExchange().get(Endpoint.class);
            Message responseMsg = new MessageImpl();
            responseMsg.setExchange(this.currentMessage.getExchange());
            responseMsg = e.getBinding().createMessage(responseMsg);
            this.currentMessage.getExchange().setInMessage(responseMsg);

            // Put the forged SOAPMessage in the new CXF message
            responseMsg.setContent(SOAPMessage.class, response);

            // Continue the execution of the interceptor chain on the new
message
            InterceptorChain chain =
this.currentMessage.getInterceptorChain();
            responseMsg.setInterceptorChain(chain);
            chain.doIntercept(responseMsg);

            // Cancel the execution of the interceptor chain on the former
message
            this.currentMessage.getInterceptorChain().abort();


Thanks
--
Marian MULLER
SERLI


On Wed, Nov 17, 2010 at 4:23 PM, Marian Muller <[email protected]>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.
>
>
> 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
>

Reply via email to