How to Assign Web Proxy

Topics: Web Api
Oct 6, 2011 at 7:39 PM

In an effort to debug the Content issue I'm having a search on using Fiddler on Azure found an entry by Andy Cross that might help figure this out. The only problem with it is that a Web Proxy would need to be called within the Web Api method and I don't know how to do that. Can someone show me how to use a Web Proxy within a method called within Web Api?

Here is a link to the article I'm considering using: http://blog.bareweb.eu/2011/01/running-fiddler-in-windows-azure-with-azurefiddlercore/

This may make sense as a DelegatingHandler, but again, how do you set a proxy within a handler?

Thanks,

\ ^ / i l l

Oct 6, 2011 at 11:22 PM

Hi Will,

Can you get the traces of the request messages using System.Net tracing. Following are example settings that you can use to trace incoming messages at the service...It would be great if you can get traces, where you make 1 request from the (working).NET client and 1 request from the Android client? You can send the trace file to my email address: kichalla@microsoft.com

There below settings were taken from here:

<?xml version="1.0" encoding="utf-8"?> 
<configuration>
	<system.diagnostics>
		<trace autoflush="true" />
		<sources>
			<source name="System.Net">
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
			<source name="System.Net.HttpListener"> 
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
			<source name="System.Net.Sockets">
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
			<source name="System.Net.Cache">
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
		</sources> 
	<sharedListeners>
		<add
		name="System.Net"
		type="System.Diagnostics.TextWriterTraceListener"
		initializeData="C:\\Tracing\\OWSTimer_SNtrace.log" traceOutputOptions = "DateTime" />
	</sharedListeners>
	<switches>
		<add name="System.Net" value="Verbose" />
		<add name="System.Net.Sockets" value="Verbose" />
		<add name="System.Net.Cache" value="Verbose" />
		<add name="System.Net.HttpListener" value="Verbose" />
	</switches>
	</system.diagnostics>
</configuration>
Thanks,
Kiran Challa
Oct 6, 2011 at 11:57 PM

Hi Kiran,

Thanks! That is cool but unfortunately not as useful as the actual Fiddler traces. What I'd like to see is the header information and content of the message as it goes in and out of the server. That's why I'd like to grab with Fiddler.

Best,

\ ^ / i l l

Oct 7, 2011 at 12:14 AM
Edited Oct 7, 2011 at 12:23 AM

Will,

You can get header and content information of incoming request & outgoing response at the Service even with System.Net tracing. Example trace snippet (Yeah, its not as pretty as what Fiddler gives :-), but i think its still useful information)

Incoming Request:

System.Net.HttpListener Information: 0 : [10408] HttpListenerRequest#59817589::.ctor(httpContext#6044116 RequestUri:http://XXXXX:8080/FoobarService/ Content-Length:60 HTTP Method:POST)
    DateTime=2011-10-06T23:19:45.5683527Z
System.Net.HttpListener Information: 0 : [10408] HttpListenerRequest#59817589::.ctor(HttpListenerRequest Headers:
 Connection : Keep-Alive
 Content-Length : 60
 Expect : 100-continue
 Host : XXXX:8080
)
    DateTime=2011-10-06T23:19:45.5683527Z
System.Net.HttpListener Warning: 0 : [10408] HttpListener#24827179::HandleAuthentication() - Received a request with an unmatched or no authentication scheme. AuthenticationSchemes:Anonymous, Authorization:<null>.
    DateTime=2011-10-06T23:19:45.5683527Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListener#24827179::EndGetContext(IAsyncResult#63835064)
    DateTime=2011-10-06T23:19:45.5693294Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListener#24827179::EndGetContext()  -> HttpListenerContext#6044116 RequestTraceIdentifier#00000000-0000-0000-1000-0080000000f0
    DateTime=2011-10-06T23:19:45.5693294Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerRequest#59817589::InputStream_get()
    DateTime=2011-10-06T23:19:45.5703061Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerRequest#59817589::InputStream_get()
    DateTime=2011-10-06T23:19:45.5703061Z
System.Net.HttpListener Verbose: 0 : [10408] HttpRequestStream#5773521::Read()
    DateTime=2011-10-06T23:19:45.5703061Z
System.Net.HttpListener Verbose: 0 : [10408] Data from HttpRequestStream#5773521::Read
    DateTime=2011-10-06T23:19:45.5703061Z
System.Net.HttpListener Verbose: 0 : [10408] 00000000 : 3C 3F 78 6D 6C 20 76 65-72 73 69 6F 6E 3D 22 31 : <?xml version="1
    DateTime=2011-10-06T23:19:45.5712828Z
System.Net.HttpListener Verbose: 0 : [10408] 00000010 : 2E 30 22 20 65 6E 63 6F-64 69 6E 67 3D 22 75 74 : .0" encoding="ut
    DateTime=2011-10-06T23:19:45.5712828Z
System.Net.HttpListener Verbose: 0 : [10408] 00000020 : 66 2D 38 22 3F 3E 3C 73-74 72 69 6E 67 3E 68 65 : f-8"?><string>he
    DateTime=2011-10-06T23:19:45.5712828Z
System.Net.HttpListener Verbose: 0 : [10408] 00000030 : 6C 6C 6F 3C 2F 73 74 72-69 6E 67 3E             : llo</string>
    DateTime=2011-10-06T23:19:45.5712828Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpRequestStream#5773521::Read()  -> dataRead:60

Outgoing Response

System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6836033Z
System.Net.HttpListener Information: 0 : [10408] HttpListenerResponse#23802763::AppendHeader( name=CustomHeader1 value=CustomHeader1-Value)
    DateTime=2011-10-06T23:19:45.6836033Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpListenerContext#6044116::Response()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Information: 0 : [10408] HttpListenerResponse#23802763::.ctor(HttpListenerResponse Headers:
 Content-Type : application/xml; charset=utf-8
 CustomHeader1 : CustomHeader1-Value
 Content-Length : 69
)
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10408] Exiting HttpResponseStream#30095983::BeginWrite()
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] Data from HttpResponseStreamAsyncResult#36848977::Callback
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] 00000000 : 3C 3F 78 6D 6C 20 76 65-72 73 69 6F 6E 3D 22 31 : <?xml version="1
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] 00000010 : 2E 30 22 20 65 6E 63 6F-64 69 6E 67 3D 22 75 74 : .0" encoding="ut
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] 00000020 : 66 2D 38 22 3F 3E 3C 73-74 72 69 6E 67 3E 68 65 : f-8"?><string>he
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] 00000030 : 6C 6C 6F 2D 72 65 73 70-6F 6E 73 65 3C 2F 73 74 : llo-response</st
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] 00000040 : 72 69 6E 67 3E                                  : ring>
    DateTime=2011-10-06T23:19:45.6845800Z
System.Net.HttpListener Verbose: 0 : [10884] HttpResponseStream#30095983::EndWrite() 

 Thanks,Kiran Challa

Nov 3, 2011 at 4:10 PM

Hi Will,

I'm glad you found my blog useful ;-)

I'm not sure of the answer to your question, I'm interested in how you could get this to work though. How would you do this with any other type of proxy (corporate for example)? The technique is the same.

Alternatively, since you can now (for quite some while too!) access Azure instances with RDP, you can actually remote desktop into the instance and run the full Fiddler program. However you may still have the problem of how to attach to your Web requests.

I hope you get your problem resolved!


Andy