Sub Application_Start() RegisterSoapExtension(GetType(TraceExtension), 1, 0) End SubIn the Global class, I added this new method to establish a hook to the SOAP enveloppe:
''' Programatically registers a <see cref="SoapExtension"/> at runtime with the specified ''' <see cref="SoapExtensionTypeElement.Priority"/> and <see cref="SoapExtensionTypeElement.Group"/> settings. ''' </summary> ''' <param name="type">The <see cref="Type"/> of the <see cref="SoapExtension"/> to register.</param> ''' <param name="priority"> ''' A value that indicates the relative order in which this SOAP extension runs when multiple SOAP extensions are ''' specified. Within each group the priority attribute distinguishes the overall relative priority of the SOAP ''' extension. A lower priority number indicates a higher priority for the SOAP extension. The lowest possible ''' value for the priority attribute is 1. ''' </param> ''' <param name="group"> ''' The relative priority group (e.g. Low or High) in which this SOAP extension runs when multiple SOAP extensions ''' are configured to run. ''' </param> <System.Security.Permissions.ReflectionPermission(System.Security.Permissions.SecurityAction.Demand, Unrestricted:=True)> _ Public Shared Sub RegisterSoapExtension(type As Type, priority As Integer, group As System.Web.Services.Configuration.PriorityGroup) If Not type.IsSubclassOf(GetType(System.Web.Services.Protocols.SoapExtension)) Then Throw New ArgumentException("Type must be derived from SoapException.", "type") End If If priority < 1 Then Throw New ArgumentOutOfRangeException("priority", priority, "Priority must be greater or equal to 1.") End If ' get the current web services settings... Dim wss As System.Web.Services.Configuration.WebServicesSection = System.Web.Services.Configuration.WebServicesSection.Current ' set SoapExtensionTypes collection to read/write... Dim readOnlyField As System.Reflection.FieldInfo = GetType(System.Configuration.ConfigurationElementCollection).GetField("bReadOnly", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance) readOnlyField.SetValue(wss.SoapExtensionTypes, False) ' inject SoapExtension... wss.SoapExtensionTypes.Add(New System.Web.Services.Configuration.SoapExtensionTypeElement(type, priority, group)) ' set SoapExtensionTypes collection back to readonly and clear modified flags... Dim resetModifiedMethod As System.Reflection.MethodInfo = GetType(System.Configuration.ConfigurationElement).GetMethod("ResetModified", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance) resetModifiedMethod.Invoke(wss.SoapExtensionTypes, Nothing) Dim setReadOnlyMethod As System.Reflection.MethodInfo = GetType(System.Configuration.ConfigurationElement).GetMethod("SetReadOnly", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance) setReadOnlyMethod.Invoke(wss.SoapExtensionTypes, Nothing) End Sub