Two-way WCF service operation does not return a response instead of an exception

I have two different WCF services that perform basically your basic CRUD operations. For both services, regardless of the client, if the service throws an exception , the exception will not be returned to the client . In fact, the only way to see the actual exception is to enable tracing in services and view the trace file.

This is true no matter which exception is thrown. For example, if I send a string value with a length greater than that allowed by my service binding configuration, it throws a NetDispatcherFaultException with the following message, as expected:

The formatter made an exception when trying to deserialize the message: an error occurred while trying to deserialize the http://tempuri.org/:newItem parameter. The InnerException message was "Error deserializing an object of type Organization.Division.Application.Service.AddNewItem. When reading XML data, the maximum string length quota (8192) was exceeded. This quota can be increased by changing the MaxStringContentLength property of the XmlDictionaryReaderQuotas object used to create the XML- Reader Line 1, Item 20157. '.

The problem is that this exception is not returned by the service; instead, the service throws an ArgumentNullException with an exception message:

The value cannot be null.
Parameter Name: Message

... ( , - ASP.NET, WCF ):

. : ; ; . . . , -, .
:
HTTP http://localhost/Services/MyAwesomeS3rv1c3/DoSomethingGrrreat.svc. , HTTP. , HTTP- , , , - . . .

, : Request/Reply AddNewItem .

, - , , , . , . , .

, <serviceBehavior><behavior>... web.config:

<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>

... wsHttpBinding mex.

, , -, (.. , ). , .

+3
2

. , -, . WCF.

( sql ), /. ServiceChannel . ArgumentNullException , .

- , . , Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write , . ( - , ) .

, , .

+1

, , , : I.e. , - , ( ), .

0

Source: https://habr.com/ru/post/1769803/


All Articles