Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soap Error: "Server was unable to process request" "Object reference not set to an instance of an object"

When I send a SOAP request to my service in the IIS locally, everything works fine. When I send a SOAP request to the same service that running on IIS on another host, everything works fine.

But when another programmer sends a SOAP request to my service, he generally gets the right response except one method in the service that returns:

<soap:Body>
<soap:Fault>
  <faultcode>soap:Server</faultcode>
  <faultstring>Server was unable to process request. ---&gt; Object reference not set to an instance of an object.</faultstring>
  <detail />
</soap:Fault>

I need to understand why he is receiving this error.

His SOAP request is exactly the same as SOAP Request yet mine works and his does not.

like image 681
Rodniko Avatar asked Mar 15 '11 14:03

Rodniko


1 Answers

The "Object reference" error is the hardest to troubleshoot if you don't know exactly where the error is occurring. Be sure to test for null values, as the most obvious cause for this error is an object not being initialized or a variable having a null value when it's expected to contain an object or a value.

Also, be sure that you're following best practices for error handling. Try to catch the errors at the earliest possible level unless you intentionally intend to let a higher-level error handler catch the error. The fact that you're getting this error means that the error handling is not sufficient.

Finally, I'd strongly recommend including some sort of logging mechanism for your error handlers. Save the errors to the Event Log, or a database, or even email them - anything, so that you can tell exactly where the error is. Do NOT display the error back to the user.

There are several options for this. Asp.Net Health Monitoring works fine in web services as well as standard asp.net sites. There's also ELMAH, or you can write your own code to do this.

If you follow these guidelines, you won't be in a situation where you don't understand how the error is happening. You'll have the information you need to troubleshoot properly, and your apps will be more solid.

like image 88
David Avatar answered Sep 17 '22 21:09

David