tags:

views:

1079

answers:

7

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.

+1  A: 

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.

Amber
I know the Http request that is sent but do not have access to modify the old code which why I was thinking of capturing the outgoing request.
A: 

You can write an HTTP Module.

santiiiii
I imagine that the problem is that he has no access to the server at the old webservice URL, hence he won't be able to host an HTTP Module there.
James McCormack
That's correct!
+1  A: 

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.

James McCormack
+2  A: 

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.

Digitalex
You are right that is an option although I want to do the translating on the PC not the web.
Ah, so this legacy application, it is not a server app, but a client app installed on people's pc's?
Digitalex
Yes that is right, it is an old program that we do not have the source code to so we need to spoof the app into thinking it is connected to the original web service
If your users are limited in number, and all trust you (such as if you're the IT department, and users are in the same organization), your could do what I proposed, and install the translation-service on each client PC. If not, hacking users' 'hosts'-files probably isn't very popular...
Digitalex
+2  A: 

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.

Darrin Lynn
Sweet solution!
James McCormack
Thanks James
Darrin Lynn
A: 

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/

Digambar Daund
A: 

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.

baranco