Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

Serializing custom exception through a webmethod call.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt Bush - 09 Nov 2004 22:21 GMT
How do I xml serialize a custom exception so it can be included as a
parameter on my webmethod?  See extra details below.

I have an audit web service which attempts to log exceptions to a database.

The web method looks like:

   <WebMethod(Description:="Log process message.")> _
   Public Function AddProcessMessage( _
           ByVal ProcessExecutionKey As Long, _
           ByVal AppEx As UserException) As Boolean

       ' Returns true if successfully logs the message and the AppEx log
flag will also be set to true.
       Return ProcessExecution.AddProcessMessage(ProcessExecutionKey, AppEx )
   End Function

This generates an error complaining about security permissions on the base
exception class, eg. properties such as 'TargetSite' can not be serialised.

Do I need to do imperative asserts or explicit demands or both.  If so could
you give me a code example that relaxes the security on xml serializing a
custom exception.

Thanks.
Christoph Schittko [MVP] - 09 Nov 2004 22:49 GMT
Matt,

The XmlSerializer, that's serializing the web service message can't deal
with exceptions [0]. You have to develop a custom wrapper that "hides"
the properties that the XmlSerializer can't process.

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

[0]
http://msdn.microsoft.com/library/en-us/dnexxml/html/xml01202003.asp?fra
me=true

> -----Original Message-----
> From: Matt Bush [mailto:Matt Bush@discussions.microsoft.com]
[quoted text clipped - 32 lines]
>
> Thanks.
Dan Rogers - 11 Nov 2004 22:54 GMT
Concur.  Rather than base your types on the internal exception types (which
are not portable), I'd suggest designing an exception base class of your
own in XSD, just like you would design a business document such as an
order.  Then, generate classes from this XSD using XSD.exe or
XSDObjectGen.exe, and build your service interface to accept the typed
classes that result.  This will give you the interface you need without
introducing underlying platform item specific serialization issues.

Regards,

Dan Rogers
Microsoft Corporation
--------------------
>Thread-Topic: Serializing custom exception through a webmethod call.
>thread-index: AcTGqmaBU5DO+l+zRoKcjT3nv7Thwg==
[quoted text clipped - 17 lines]
>Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:26429
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
>
[quoted text clipped - 23 lines]
>
>Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.