Advice and help required
-
Hi, This is what i would like to happen! 1. I have a web service and a consuming web application. From within the web app i want to record the round trip time from invoking to getting the data returned. What is the best way to do this? Is there a class i can use? 2. when VS creates the XML file from my request and then the responce, i want to be able to save the XML file so i can see what size it is? and is there anyway to save the data in binary form to see the difference in size? All this is coming from part of my uni thesis! I want to analyse the cost of using XML and web services compared to having common functionality built into every application! I realise this is a lot to ask but any comments, suggestions, CODE is greatly appreciated. Thanks Colin
-
Hi, This is what i would like to happen! 1. I have a web service and a consuming web application. From within the web app i want to record the round trip time from invoking to getting the data returned. What is the best way to do this? Is there a class i can use? 2. when VS creates the XML file from my request and then the responce, i want to be able to save the XML file so i can see what size it is? and is there anyway to save the data in binary form to see the difference in size? All this is coming from part of my uni thesis! I want to analyse the cost of using XML and web services compared to having common functionality built into every application! I realise this is a lot to ask but any comments, suggestions, CODE is greatly appreciated. Thanks Colin
On the client side within the web service proxy class you can override the WebRequest() method to get the returned data size. No need to save the contents to disk. 1) Before the client invokes, save the time. 2) In public override WebRequest(..) save the data size (on request and response) 3) When the invoke returns save the time and calc the differences. Good Luck. -John
-
On the client side within the web service proxy class you can override the WebRequest() method to get the returned data size. No need to save the contents to disk. 1) Before the client invokes, save the time. 2) In public override WebRequest(..) save the data size (on request and response) 3) When the invoke returns save the time and calc the differences. Good Luck. -John
Thanks where can override this method? i have the web service as a web reference (visual studio) within my client thanks again for your help Colin
-
Thanks where can override this method? i have the web service as a web reference (visual studio) within my client thanks again for your help Colin
One approach: Right-click on the reference to the web service. View in Object Browser Browse to the class object for the web service. Right-click Go To Definition type:
protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request) { return base.GetWebResponse (request); }
Just remember, if you "Update Web Reference" any code you've created will be overwritten. -John -
One approach: Right-click on the reference to the web service. View in Object Browser Browse to the class object for the web service. Right-click Go To Definition type:
protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request) { return base.GetWebResponse (request); }
Just remember, if you "Update Web Reference" any code you've created will be overwritten. -JohnThanks John, im learning a lot here! as im overriding this method do i have to explicitly call it, or would i have to do this anyway? For my problem where/how do i call this and what type do i save the return as? Thanks Colin
-
Thanks John, im learning a lot here! as im overriding this method do i have to explicitly call it, or would i have to do this anyway? For my problem where/how do i call this and what type do i save the return as? Thanks Colin
Colin, Here's the basic override code. I write a static function called Logger() to write the info to a textbox; you'd want to probably write to a text file or database. For some reason the response length is -1 if you get it off the object itself. You can get the response length if you read the entire stream like I've done. This is all BEFORE deserialization so you're timing will be off a bit. You don't have to explicitly call anything. These are base methods you're overriding and the proxy is taking care of calling them for you. protected override System.Net.WebRequest GetWebRequest(Uri uri) { PersonClient.Form1.Logger("startTime=" + System.DateTime.Now); return base.GetWebRequest (uri); } protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request) { System.IO.StreamReader sr = new System.IO.StreamReader(request.GetResponse().GetResponseStream()); string buffer = sr.ReadToEnd(); sr.Close(); PersonClient.Form1.Logger("ReqLen=" + request.ContentLength); //request.GetResponse().GetResponseStream().Length; PersonClient.Form1.Logger("ResLen=" + buffer.Length ); PersonClient.Form1.Logger("endTime=" + System.DateTime.Now); return base.GetWebResponse (request); } -John
-
Colin, Here's the basic override code. I write a static function called Logger() to write the info to a textbox; you'd want to probably write to a text file or database. For some reason the response length is -1 if you get it off the object itself. You can get the response length if you read the entire stream like I've done. This is all BEFORE deserialization so you're timing will be off a bit. You don't have to explicitly call anything. These are base methods you're overriding and the proxy is taking care of calling them for you. protected override System.Net.WebRequest GetWebRequest(Uri uri) { PersonClient.Form1.Logger("startTime=" + System.DateTime.Now); return base.GetWebRequest (uri); } protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request) { System.IO.StreamReader sr = new System.IO.StreamReader(request.GetResponse().GetResponseStream()); string buffer = sr.ReadToEnd(); sr.Close(); PersonClient.Form1.Logger("ReqLen=" + request.ContentLength); //request.GetResponse().GetResponseStream().Length; PersonClient.Form1.Logger("ResLen=" + buffer.Length ); PersonClient.Form1.Logger("endTime=" + System.DateTime.Now); return base.GetWebResponse (request); } -John
thanks John ill give it a try Colin
-
Colin, Here's the basic override code. I write a static function called Logger() to write the info to a textbox; you'd want to probably write to a text file or database. For some reason the response length is -1 if you get it off the object itself. You can get the response length if you read the entire stream like I've done. This is all BEFORE deserialization so you're timing will be off a bit. You don't have to explicitly call anything. These are base methods you're overriding and the proxy is taking care of calling them for you. protected override System.Net.WebRequest GetWebRequest(Uri uri) { PersonClient.Form1.Logger("startTime=" + System.DateTime.Now); return base.GetWebRequest (uri); } protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request) { System.IO.StreamReader sr = new System.IO.StreamReader(request.GetResponse().GetResponseStream()); string buffer = sr.ReadToEnd(); sr.Close(); PersonClient.Form1.Logger("ReqLen=" + request.ContentLength); //request.GetResponse().GetResponseStream().Length; PersonClient.Form1.Logger("ResLen=" + buffer.Length ); PersonClient.Form1.Logger("endTime=" + System.DateTime.Now); return base.GetWebResponse (request); } -John
John I created a public Void Logger(string strIn) which saves the string to a database How can i get access to this from the GetWebResponse method? I tried WebForm1.Logger("Length" + request.ContentLength) but i get an error would it be possible to e-mail your sample application to me? cm@gowcity.fsnet.co.uk Thanks a lot Colin