internal override bool Initialize() { // try to guess the request version so we can handle any exceptions that might come up GuessVersion(); message = new SoapServerMessage(this); onewayInitException = null; serverType = (SoapServerType)GetFromCache(typeof(SoapServerProtocol), Type); if (serverType == null) { lock (Type){ serverType = (SoapServerType)GetFromCache(typeof(SoapServerProtocol), Type); if (serverType == null) { serverType = new SoapServerType(Type, versionsSupported); AddToCache(typeof(SoapServerProtocol), Type, serverType); } } } // We delay throwing any exceptions out of the extension until we determine if the method is one-way or not. Exception extensionException = null; try { message.highPriConfigExtensions = SoapMessage.InitializeExtensions(serverType.HighPriExtensions, serverType.HighPriExtensionInitializers); // For one-way methods we rely on Request.InputStream guaranteeing that the entire request body has arrived message.SetStream(Request.InputStream); Debug.Assert(message.Stream.CanSeek, "Web services SOAP handler assumes a seekable stream."); message.InitExtensionStreamChain(message.highPriConfigExtensions); message.SetStage(SoapMessageStage.BeforeDeserialize); message.ContentType = Request.ContentType; message.ContentEncoding = Request.Headers[ContentType.ContentEncoding]; message.RunExtensions(message.highPriConfigExtensions); } catch (Exception e) { extensionException = e; } // set this here since we might throw before we init the other extensions message.allExtensions = message.highPriConfigExtensions; // maybe the extensions that just ran changed some of the request data so we can make a better version guess GuessVersion(); try { this.serverMethod = helper.RouteRequest(); // the RouteRequest impl should throw an exception if it can't route the request but just in case... if (this.serverMethod == null) { throw new SoapException(Res.GetString(Res.UnableToHandleRequest0), new XmlQualifiedName(Soap.ServerCode, Soap.Namespace)); } } catch (Exception) { if (helper.RequestNamespace != null) { SetHelper(SoapServerProtocolHelper.GetHelper(this, helper.RequestNamespace)); } // version mismatches override other errors CheckHelperVersion(); throw; } this.isOneWay = serverMethod.oneWay; if (extensionException == null) { try { SoapReflectedExtension[] otherReflectedExtensions = (SoapReflectedExtension[])CombineExtensionsHelper(serverMethod.extensions, serverType.LowPriExtensions, typeof(SoapReflectedExtension)); object[] otherInitializers = (object[])CombineExtensionsHelper(serverMethod.extensionInitializers, serverType.LowPriExtensionInitializers, typeof(object)); message.otherExtensions = SoapMessage.InitializeExtensions(otherReflectedExtensions, otherInitializers); message.allExtensions = (SoapExtension[])CombineExtensionsHelper(message.highPriConfigExtensions, message.otherExtensions, typeof(SoapExtension)); } catch (Exception e) { extensionException = e; } } if (extensionException != null) { if (isOneWay) { onewayInitException = extensionException; } else { throw new SoapException(Res.GetString(Res.WebConfigExtensionError), new XmlQualifiedName(Soap.ServerCode, Soap.Namespace), extensionException); } } return(true); }