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

前端 未结 2 1490
轻奢々
轻奢々 2021-01-04 04:15

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, every

相关标签:
2条回答
  • 2021-01-04 04:49

    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.

    0 讨论(0)
  • 2021-01-04 04:52

    Thanks guys for all your help. I solved the problem.

    The 'SoapAction' field in the soap request had the wrong URI

    I recommend using a HTTP sniffer. The http sniffer will show the SOAP properties.

    The "SOAPAction" property should have something like : http://tempuri.org/YourServiceMethodName

    0 讨论(0)
提交回复
热议问题