Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   Serializing custom exception through a webmethod call. (http://www.velocityreviews.com/forums/t784029-serializing-custom-exception-through-a-webmethod-call.html)

Matt Bush 11-09-2004 10:21 PM

Serializing custom exception through a webmethod call.
 
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(ProcessExecutio nKey, 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.

Dan Rogers 11-11-2004 10:54 PM

RE: Serializing custom exception through a webmethod call.
 
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==
>X-WBNR-Posting-Host: 203.57.240.95
>From: =?Utf-8?B?TWF0dCBCdXNo?= <Matt Bush@discussions.microsoft.com>
>Subject: Serializing custom exception through a webmethod call.
>Date: Tue, 9 Nov 2004 14:21:03 -0800
>Lines: 25
>Message-ID: <B93D77D1-B9C6-4A3F-AF6B-5D81B326C9D2@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: cpmsftngxa10.phx.gbl

microsoft.public.dotnet.framework.aspnet.webservic es:26429
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>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(ProcessExecutio nKey,

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.
>




All times are GMT. The time now is 03:20 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57