Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Advice and help required

Advice and help required

Scheduled Pinned Locked Moved Web Development
questionvisual-studiowcfxmlhelp
8 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    colin mcadam
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • C colin mcadam

      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

      J Offline
      J Offline
      john3parker
      wrote on last edited by
      #2

      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

      C 1 Reply Last reply
      0
      • J john3parker

        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

        C Offline
        C Offline
        colin mcadam
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • C colin mcadam

          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

          J Offline
          J Offline
          john3parker
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • J john3parker

            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

            C Offline
            C Offline
            colin mcadam
            wrote on last edited by
            #5

            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

            J 1 Reply Last reply
            0
            • C colin mcadam

              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

              J Offline
              J Offline
              john3parker
              wrote on last edited by
              #6

              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

              C 2 Replies Last reply
              0
              • J john3parker

                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

                C Offline
                C Offline
                colin mcadam
                wrote on last edited by
                #7

                thanks John ill give it a try Colin

                1 Reply Last reply
                0
                • J john3parker

                  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

                  C Offline
                  C Offline
                  colin mcadam
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups