A custom SOAP fault handler and a ‘Reference not set to an instance of an object’ error …
By rickvdbosch
- 2 minutes read - 382 wordsToday we had a problem on the project I am working on. To be more precise: I had a problem, the other team members did not.
Quick explanation: We have a server component which uses a web service for some of the functionality we need. Other functionality can be found in a different system which is reachable through IBM WebSphere MQ. The server component is available through remoting, the objects are hosted in IIS. To get decent SOAP errors someone on the team created a custom SOAPFaultHandler and included it in the web.config of the server component. So far so good.
When trying to request a typed DataSet at the front end application all the way from the web service (so through the remoting objects of the server) I got a ‘reference not set to an instance of an object’ error. Strange, because nobody on the team mentioned anything about this and it concerned key functionality. Stepping though code I found that the web service worked decently: the typed dataset was returned successfully to the server. Stepping further, the server component looked OK also: the dataset was available everywhere up to the Service Interface layer (facade layer). But still I got that same error at the client application…
Finally, after some intense debugging, I got to the SOAPFaultHandler and decided to attach that to the aspnet_wp process to see if that might cause the problem. And it did! There was a check on the existence of the header, but it was not checked for items: the first item was read without checking for existence. That caused my version of this complete system to break.
I corrected the error and things were fine, but I couldn’t find a reason for this weird behaviour. Why did I have the problem but no one else? I think I figured it out when I found out everybody had WSE 2.0 installed, except me. It looks like WSE 2.0 fixes something around SOAP errors so there aren’t any when they are not necessary, or the ones that are there are complete ones. We had a deadline today, so I didn’t investigate any further. But I think I’ll try to find the real reason the following week. And when I find the true reason, I’ll keep you posted.