Results 1 to 9 of 9

Thread: Passing exceptions across a web service.

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Passing exceptions across a web service.

    Our app calls a web service, which in turns calls a DLL, which does something to the DB.
    If there is an error in the DB code, how would you pass the exception back to the UI?

    Woka

  2. #2
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Passing exceptions across a web service.

    Is the Web Service yours?
    If it is create a return object that can contain all the information you want the service to pass back. This way you can give your return object a bool OK property to check and if it is false have an ArrayList of strings that contains any applicable error messages.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing exceptions across a web service.

    I let the exception bubble up to the thin client. For example, when the db layer throws an exception, it goes to the web service, the web service passes it to the asp.net page, where it's handled.

  4. #4

  5. #5

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing exceptions across a web service.

    It comes to the page as a SoapException. I look at its base exception

  7. #7

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing exceptions across a web service.

    You can use the GetBaseException function, which will return an exception.

  9. #9

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Passing exceptions across a web service.

    We had a web service with the folloiwng style of functions:
    VB Code:
    1. Public Function AllUsersForPip(ByVal PipKey As Integer, ByRef ErrorEnum As enmCustomErrors) As DataSet
    2.             Try
    3.                ErrorEnum = enmCustomErrors.Success
    4.                Return m_ApplesWS.AllUsersForPip(PipKey)
    5.             Catch
    6.                ErrorEnum = enmCustomErrors.SessionTimeout
    7.             End Try
    8.     End Function
    I changed this to:
    VB Code:
    1. Public Function AllUsersForPip(ByVal PipKey As Integer) As DataSet
    2.           Return m_ApplesWS.AllUsersForPip(PipKey)
    3.     End Function
    Much simpler...if the session is timed out then a custom exception is raised from within m_ApplesWS.

    We had over 50 functions that all did this....POINTLESS!
    All err info was lost as regardless of the error no info got passed back to the UI from the web service

    I have now removed all these daft error enums from functions, and other developers here are not happy coz they wrote it a few weeks ago. Oooops.
    Well not my fault it was wrong

    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width