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. General Programming
  3. Visual Basic
  4. Web Service timeout

Web Service timeout

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
2 Posts 2 Posters 0 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.
  • D Offline
    D Offline
    Diego F
    wrote on last edited by
    #1

    Hello. I'm migrating an application that connects to a remote machine. Before it used sockets, and now a web service. I'm not sure about how to control the time to wait for a response. I'm looking for a kind of timer that waits some time and if it has no response, throws an exception. How can I do that?

    Regards, Diego F.

    K 1 Reply Last reply
    0
    • D Diego F

      Hello. I'm migrating an application that connects to a remote machine. Before it used sockets, and now a web service. I'm not sure about how to control the time to wait for a response. I'm looking for a kind of timer that waits some time and if it has no response, throws an exception. How can I do that?

      Regards, Diego F.

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      You can set the amount of time the webservice will work before sending back an error by setting the executionTimeout attribute in the web.config. Just like you would for a website, like this: <httpRuntime executionTimeout="180"/> Then you can put your call to the webservice in a try catch block. The timeout error is a System.Net.WebException. You may want to make sure the message includes the correct error message, though, since there are other System.Net.WebExceptions that could fire. So it would look something like this:

      Try
      myWebService.MyWebServiceMethod(parm1)
      Catch ex as System.Net.WebException
      If ex.Message.ToUpper.Contains("TIMED OUT") Then
      msgbox("Web service method timed out.")
      Else
      msgbox("Web error: " & ex.Message)
      End If
      Catch ex as Exception
      msgbox("Error: " & ex.Message)
      End Try

      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