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. C#
  4. Parsing incoming DateTime in C# WebService myself?

Parsing incoming DateTime in C# WebService myself?

Scheduled Pinned Locked Moved C#
questioncsharphtmlwcftesting
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.
  • T Offline
    T Offline
    Thomas ST
    wrote on last edited by
    #1

    I have a method in my Webservice:

    [WebMethod]
    public ReturnList GetList(string id, System.DateTime fromDate)

    If I enter a invalid date when testing the service, I get a custom html-page with the errormessage and a stacktrace. How can I get rid of this? I want to handle the parsing of the incoming date myself, and send back a ReturnList object with a custom errormessage.. But I don't want to use string instead of dateTime, since I want it to be specified as dateTime in the wsdl..

    S 1 Reply Last reply
    0
    • T Thomas ST

      I have a method in my Webservice:

      [WebMethod]
      public ReturnList GetList(string id, System.DateTime fromDate)

      If I enter a invalid date when testing the service, I get a custom html-page with the errormessage and a stacktrace. How can I get rid of this? I want to handle the parsing of the incoming date myself, and send back a ReturnList object with a custom errormessage.. But I don't want to use string instead of dateTime, since I want it to be specified as dateTime in the wsdl..

      S Offline
      S Offline
      student_rhr
      wrote on last edited by
      #2

      What about using an overload that way if it is passed in as something other then a valid DateTime object it will get treated by the overlaoded method and there you can try parsing it manually:

      [WebMethod]
      public ReturnList GetList(string id, string fromDate)
      {
          // overlaod
          // your parsing logic
      }
      [WebMethod]
      public ReturnList GetList(string id, System.DateTime fromDate)
      {
          // Original function
      }
      

      Worth a try ... hth

      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