I am trying to develop a C# application that will intercept an outgoing Http request and return a result to an old system. We have a legacy system that makes an Http request to a discontinued web service. I need to intercept the out going request and send it to a new web service. When the response comes back I need to manipulate it then send it on to the legacy system. All the code needs to sit on the client machine. I thought something along the lines of http listener would work but I am not getting anywhere with that, any suggestions would be greatly appreciated.
Does the legacy system support the specification of an http proxy? If so, that's probably what you want to do - write something that acts as a proxy, and point the old system at it.
If your legacy system can use a proxy as Dav suggests, you might be able to use something like Foxy to do the redirect. I'm not sure, but I believe some software uses IE for HTTP transport so try setting the HTTP proxy in IE on the client machine?
If not I think this a tough problem, as essentially you are trying to intercept and modify TCP/IP traffic, whic I think might only be possible with an advanced firewall or router.
If this is running on a Windows server, you can edit the 'hosts'-file, in order to redirect the request to some other server, including the same host (localhost) if you want. There, you can have the intermediate web service translating the request and the response.
Thanks everyone for your suggestions, here is the answer.
I have used Fiddler2 from Eric Lawrence to act as a proxy for me. I then wrote a Fiddler extension which intercepted the particular Http request I was interested in and voila.
tcpmon is an open-source utility for monitoring the data flowing on a TCP connection. tcpmon is used by placing it in-between a client and a server. The client is made to connect to tcpmon, and tcpmon forwards the data to server along-with displaying it in its GUI. https://tcpmon.dev.java.net/
You can use Membrane SOA Router, an open source reverse proxy for HTTP and SOAP. The router is rule based and also supports URL rewritting. It is possible to send requests to other endpoints without writing code. But you can also extend the proxy using its Java API.