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. ASP.NET
  4. Handling a SoapException

Handling a SoapException

Scheduled Pinned Locked Moved ASP.NET
questionwcfsysadmindata-structuresdebugging
5 Posts 3 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.
  • D Offline
    D Offline
    dubbele onzin
    wrote on last edited by
    #1

    Hi, I call a web service method and if it fails I get a load of Soap error stuff that I don't want: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: MyErrorMsgString. at MyWebService.TestThrowException() --- End of inner exception stack trace --- How can I get it to just display the error message I want? In the stuff above I just want to get the MyErrorMsgString text. Thanks :)

    G 1 Reply Last reply
    0
    • D dubbele onzin

      Hi, I call a web service method and if it fails I get a load of Soap error stuff that I don't want: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: MyErrorMsgString. at MyWebService.TestThrowException() --- End of inner exception stack trace --- How can I get it to just display the error message I want? In the stuff above I just want to get the MyErrorMsgString text. Thanks :)

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The InnerException property of the SOAP exception contains the exception from the server.

      Experience is the sum of all the mistakes you have done.

      D 1 Reply Last reply
      0
      • G Guffa

        The InnerException property of the SOAP exception contains the exception from the server.

        Experience is the sum of all the mistakes you have done.

        D Offline
        D Offline
        dubbele onzin
        wrote on last edited by
        #3

        Thanks for replying :) The message shows the inner exception though - it has all that extra text around it and that's what I don't want. It seems that when I get an error message back from a web service I've written, it contains all that extra stuff. I just want it to send back the error text I provide not all that other stuff.

        T G 2 Replies Last reply
        0
        • D dubbele onzin

          Thanks for replying :) The message shows the inner exception though - it has all that extra text around it and that's what I don't want. It seems that when I get an error message back from a web service I've written, it contains all that extra stuff. I just want it to send back the error text I provide not all that other stuff.

          T Offline
          T Offline
          thowra
          wrote on last edited by
          #4

          Make sure your web service is throwing an actual SoapException rather than just an Exception. You can throw one as easily as this:

          throw new SoapException("My Error Text", SoapException.ClientFaultCode);

          You'll get a more "concise" message that way. For more general information see here[^].

          Evil cannot be conquered in the world... It can only be resisted within oneself.

          1 Reply Last reply
          0
          • D dubbele onzin

            Thanks for replying :) The message shows the inner exception though - it has all that extra text around it and that's what I don't want. It seems that when I get an error message back from a web service I've written, it contains all that extra stuff. I just want it to send back the error text I provide not all that other stuff.

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Read my previous post. Repeat until it sinks in. If it doesn't sink in, ask about what it is that you don't understand.

            Experience is the sum of all the mistakes you have done.

            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