You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Andriy Redko <dr...@gmail.com> on 2019/08/24 15:54:05 UTC

Re: Need help to capture both HTTP Request and its Corresponding HTTP Response inside same Interceptor

Hi Vishvesh,

I assume you are asking about JAX-WS/SOAP, you may find this mail thread relevant [1], thank you.

[1] http://cxf.547215.n5.nabble.com/Log-incoming-message-with-the-corresponding-response-td5763314.html

Best Regards,
    Andriy Redko

VY> Hi Team,

VY> I have a use case in which I have been asked to capture all  HTTP Requests and their corresponding HTTP Responses inside an interceptor.
VY> I referred various online links but of no use.
VY> If possible can you please help me with how it can be achieved using a single apache cxf interceptor.

VY> Please let me know if I am not clear with the requirement.

VY> Cheers,
VY> Vishvesh


Re: Need help to capture both HTTP Request and its Corresponding HTTP Response inside same Interceptor

Posted by Andriy Redko <dr...@gmail.com>.
Hi Vishvesh,

You could implement the desired use case using Correlation Id, which could be propagated along
with request to Kafka topic (using headers fe). Using this Correlation Id, the responses could be 
published to Kafka topic, and later matched to the request.

For JAR-RS, it is even simpler, since you have ContainerResponseFilter [1] and ContainerRequestFilter [2], 
which include Request and Response contexts. I think the CXF does not bundle the illustrative example 
for your case (guys please correct me if I am wrong), but the idea is pretty simple: associate the 
Correlation Id with request context and than match it with response. So you basically have a single 
class to manage that (as you initially intended I believe). Hope it helps, thank you.

[1] https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerResponseFilter.html
[2] https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerRequestFilter.html

Best Regards,
    Andriy Redko


VY> Hi Redko ,


VY>  Thanks a ton for the quick reply .
VY>  Actually I already have gone through that link before writing to the community, but as  I am very new to the cxf Interceptor so not exactly sure how it can help me.


VY>  Here is my full scenario.


VY>  "I have an application consisting of  bunch of services written in JAX-RS which in return gives the output in
VY> JSON. Now I have to run two different instances of this application each connecting to a different vendor of
VY> database , one is connecting with SQL  Server and the other instance with IBM DB2. Now the initial ask was to
VY> capture all the http requests with all its details whatsoever was made on the instance with  SQL Server and replay
VY> the captured http requests on to the other instance i.e. the one running  with IBM DB2 . I achieved this by writing
VY> a custom Interceptor extended from AbstractPhaseInterceptor and inside my custom interceptor I captured all the
VY> required details created a POJO out of it and pushed that POJO to a Kakfa Topic, on the other instance  the same
VY> kafka topic was been listened and the same http  requests were made, the journey so far was easier.


VY>  Now along with the existing details I also have to capture the http responses of those http requests so that the
VY> behavior can be tested that both of the instances are in sync and responding in the same manner. So basically in my
VY> POJO to kafka queue along with  the existing details I also have to add their corresponding http responses , and
VY> that's the thing where I am stuck and seeking assistance for."




VY>  Cheers
VY>  Vishvesh




VY> From: Andriy Redko <dr...@gmail.com>
VY> Sent: Saturday, August 24, 2019 9:24 PM
VY> To: Vishvesh Yadav <vi...@outlook.com>; dev@cxf.apache.org <de...@cxf.apache.org>; user@cxf.apache.org <us...@cxf.apache.org>
VY> Subject: Re: Need help to capture both HTTP Request and its Corresponding HTTP Response inside same Interceptor
VY>  
VY> Hi Vishvesh,

VY>  I assume you are asking about JAX-WS/SOAP, you may find this mail thread relevant [1], thank you.

VY>  [1]  http://cxf.547215.n5.nabble.com/Log-incoming-message-with-the-corresponding-response-td5763314.html

VY>  Best Regards,
VY>      Andriy Redko

 VY>> Hi Team,

 VY>> I have a use case in which I have been asked to capture all  HTTP Requests and their corresponding HTTP Responses inside an interceptor.
 VY>> I referred various online links but of no use.
 VY>> If possible can you please help me with how it can be achieved using a single apache cxf interceptor.

 VY>> Please let me know if I am not clear with the requirement.

 VY>> Cheers,
 VY>> Vishvesh



Re: Need help to capture both HTTP Request and its Corresponding HTTP Response inside same Interceptor

Posted by Vishvesh Yadav <vi...@outlook.com>.
Hi Redko ,

Thanks a ton for the quick reply .
Actually I already have gone through that link before writing to the community, but as  I am very new to the cxf Interceptor so not exactly sure how it can help me.

Here is my full scenario.

"I have an application consisting of  bunch of services written in JAX-RS which in return gives the output in JSON. Now I have to run two different instances of this application each connecting to a different vendor of database , one is connecting with SQL Server and the other instance with IBM DB2. Now the initial ask was to capture all the http requests with all its details whatsoever was made on the instance with  SQL Server and replay the captured http requests on to the other instance i.e. the one running with IBM DB2 . I achieved this by writing a custom Interceptor extended from AbstractPhaseInterceptor and inside my custom interceptor I captured all the required details created a POJO out of it and pushed that POJO to a Kakfa Topic, on the other instance the same kafka topic was been listened and the same http  requests were made, the journey so far was easier.

Now along with the existing details I also have to capture the http responses of those http requests so that the behavior can be tested that both of the instances are in sync and responding in the same manner. So basically in my POJO to kafka queue along with the existing details I also have to add their corresponding http responses , and that's the thing where I am stuck and seeking assistance for."


Cheers
Vishvesh
________________________________
From: Andriy Redko <dr...@gmail.com>
Sent: Saturday, August 24, 2019 9:24 PM
To: Vishvesh Yadav <vi...@outlook.com>; dev@cxf.apache.org <de...@cxf.apache.org>; user@cxf.apache.org <us...@cxf.apache.org>
Subject: Re: Need help to capture both HTTP Request and its Corresponding HTTP Response inside same Interceptor

Hi Vishvesh,

I assume you are asking about JAX-WS/SOAP, you may find this mail thread relevant [1], thank you.

[1] http://cxf.547215.n5.nabble.com/Log-incoming-message-with-the-corresponding-response-td5763314.html

Best Regards,
    Andriy Redko

VY> Hi Team,

VY> I have a use case in which I have been asked to capture all  HTTP Requests and their corresponding HTTP Responses inside an interceptor.
VY> I referred various online links but of no use.
VY> If possible can you please help me with how it can be achieved using a single apache cxf interceptor.

VY> Please let me know if I am not clear with the requirement.

VY> Cheers,
VY> Vishvesh