liuhaipeng905 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 1 forks source link

Null value exception on unspecified service #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Right now, if a call is attempted to a service that does not exist, a 
null-value exception is created.  Do I have a configuration error somewhere or 
is it possible to make a change so that a 404 response is created instead of an 
exception?

Thanks,
Dave

Original issue reported on code.google.com by dave.w.murphy on 22 Jun 2010 at 4:51

GoogleCodeExporter commented 9 years ago
Hi Dave,

Definitely a more appropriate 500 'Service Not Found / Implemented' error 
message should've been returned instead. Can you let me know the OS .NET 
platform that you're using?

Original comment by demis.be...@gmail.com on 22 Jun 2010 at 4:54

GoogleCodeExporter commented 9 years ago
Also can you attach the StackTrace that you're getting if any. 

P.S. By 'OS .NET Platform' I mean which version of Windows or Linux are you 
using and what version of .NET or Mono. 

Original comment by demis.be...@gmail.com on 22 Jun 2010 at 4:57

GoogleCodeExporter commented 9 years ago
It's .Net 4.0/IIS 7.0/Server 2008.  Thanks for your quick response and help!

Here is the stack trace:
In File: /Public/Json/SyncReply
Date: 6/22/2010 10:02:54 AM
Error: System.ArgumentNullException: Value cannot be null. 
Parameter name: key
Source: mscorlib
Stack trace:
System.ArgumentNullException: Value cannot be null. 
Parameter name: key 
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key) 
at 
ServiceStack.ServiceModel.Serialization.KeyValueDataContractDeserializer.Parse(I
Dictionary`2 keyValuePairs, Type returnType) 
at ServiceStack.WebHost.Endpoints.Support.JsonHandlerBase.CreateRequest(String 
operationName, String httpMethod, NameValueCollection queryString, 
NameValueCollection requestForm, Stream inputStream) 
at 
ServiceStack.WebHost.Endpoints.Support.JsonHandlerBase.CreateRequest(HttpRequest
 request, String operationName) 
at 
ServiceStack.WebHost.Endpoints.JsonSyncReplyHandler.ProcessRequest(HttpContext 
context) 
at 
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.I
ExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& 
completedSynchronously)

Original comment by dave.w.murphy on 22 Jun 2010 at 5:03

GoogleCodeExporter commented 9 years ago
Hi Dave,

Can I have a look at the HTTP Url you are using that generates the error as 
based on the StackTrace it looks like the error might be caused by the 
querystring params instead of the missing service.

Original comment by demis.be...@gmail.com on 22 Jun 2010 at 5:35

GoogleCodeExporter commented 9 years ago
There are are no querystring params.  The URL is 
'https://localhost/Public/Json/SyncReply/Tests' (where 
'https://localhost/Public/Json/SyncReply/Test' is a valid service and works 
just fine).

Here's a copy of the yellow page error (the previous stacktrace was from my 
exception logger/handler) and screenshots attached.

Server Error in '/' Application.
Value cannot be null.
Parameter name: key
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information about 
the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: key

Source Error:

An unhandled exception was generated during the execution of the current web 
request. Information regarding the origin and location of the exception can be 
identified using the exception stack trace below.

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: key]
   System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +12670101
   ServiceStack.ServiceModel.Serialization.KeyValueDataContractDeserializer.Parse(IDictionary`2 keyValuePairs, Type returnType) +69
   ServiceStack.WebHost.Endpoints.Support.JsonHandlerBase.CreateRequest(String operationName, String httpMethod, NameValueCollection queryString, NameValueCollection requestForm, Stream inputStream) +746
   ServiceStack.WebHost.Endpoints.Support.JsonHandlerBase.CreateRequest(HttpRequest request, String operationName) +109
   ServiceStack.WebHost.Endpoints.JsonSyncReplyHandler.ProcessRequest(HttpContext context) +160
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +597
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +266

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET 
Version:4.0.30319.1 

Original comment by dave.w.murphy on 22 Jun 2010 at 5:45

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Dave, thanks for the detailed StackTrace and screen-shots, it helped track 
down the issue:

It seems that I wasn't extending the same error handling love found in my Xml 
endpoint to the other JSON/JSV endpoints! 
This should now be resolved with the latest binaries (v1.36+) and you should 
hopefully get a more appropriate error message.

I'm having some delay problems uploading new versions of the binaries to 
code-project (it looks like a CDN/cache issue with the new release of google 
code). So I've attached the binaries on this comment for you to try.

Can you let me know if you get a more appropriate error?

Original comment by demis.be...@gmail.com on 22 Jun 2010 at 11:54

Attachments:

GoogleCodeExporter commented 9 years ago
Yes, much better.  500 status returned and no exceptions are raised.

Cheers, thanks.

-Dave

Original comment by dave.w.murphy on 23 Jun 2010 at 7:14

GoogleCodeExporter commented 9 years ago

Original comment by demis.be...@gmail.com on 23 Jun 2010 at 9:22