NOTE: Using .NET 2.0, and VS2005 as IDE
Hello all,
I'm working on logging webservice calls to our database, and finally got the SoapExtension configured and running using a very stripped-down implementation that was ported over from another project. I've set it up in the configuration file so it will run for all methods. When I call my webservice, and the soap extension fires, a NullPointerException is thrown when the SoapServerMessage attempts to call its MethodInfo property:
System.Web.Services.Protocols.SoapException: There was an exception running the extensions specified in the config file.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.Services.Protocols.SoapServerProtocol.get_MethodInfo()
at System.Web.Services.Protocols.SoapServerMessage.get_MethodInfo()
at MyService.SOAPLoggingExtension.LogInput(SoapMessage message)
at MyService.SOAPLoggingExtension.ProcessMessage(SoapMessage message)
at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
The LogInput method is called during the BeforeDeserialize stage of ProcessMessage(SoapMessage):
SoapMessageStage.BeforeDeserialize:
CopyStream(_oldStream, _newStream);
_newStream.Position = 0;
if(_enabled)
LogInput(message);
break;
And the LogInput method is failing when attempting to access the MethodInfo property of the message object it is trying to log. Here is the block of code where the property is called:
entry = new MyServerLogEntry();
entry.ServerURL = message.Url;
entry.Method = (message.MethodInfo == null) ? null : message.MethodInfo.Name;
When message.MethodInfo is called, it bubbles over to SoapServerProtocol.get_MethodInfo(), and the null reference exception gets thrown in there. I've googled, and checked around here on Stack Overflow, but haven't been able to find out why the MethodInfo property would be throwing an exception.
Does anyone know how to ensure this MethodInfo property is properly initialized during the web service call?
ADDITIONAL DETAILS: If I do not attempt to access the MethodInfo property, the extension works correctly and logs to my database.