public void Reflect(Type type, string url) { XmlSchemaExporter schemaExporter = new XmlSchemaExporter(Schemas); SoapSchemaExporter soapSchemaExporter = new SoapSchemaExporter(Schemas); if (WSConfig.IsSupported(WSProtocol.HttpSoap)) { new Soap11ProtocolReflector().Reflect(this, type, url, schemaExporter, soapSchemaExporter); } #if NET_2_0 if (WSConfig.IsSupported(WSProtocol.HttpSoap12)) { new Soap12ProtocolReflector().Reflect(this, type, url, schemaExporter, soapSchemaExporter); } #endif if (WSConfig.IsSupported(WSProtocol.HttpGet)) { new HttpGetProtocolReflector().Reflect(this, type, url, schemaExporter, soapSchemaExporter); } #if ONLY_1_1 if (WSConfig.IsSupported(WSProtocol.HttpPost) || WSConfig.IsSupported(WSProtocol.HttpPostLocalhost)) #else if (WSConfig.IsSupported(WSProtocol.HttpPost)) #endif { new HttpPostProtocolReflector().Reflect(this, type, url, schemaExporter, soapSchemaExporter); } int i = 0; while (i < types.Schemas.Count) { if (types.Schemas[i].Items.Count == 0) { types.Schemas.RemoveAt(i); } else { i++; } } if (serviceDescriptions.Count == 1) { serviceDescriptions[0].Types = types; } else { foreach (ServiceDescription d in serviceDescriptions) { d.Types = new Types(); for (int n = 0; n < types.Schemas.Count; n++) { ProtocolReflector.AddImport(d, types.Schemas[n].TargetNamespace, GetSchemaUrl(url, n)); } } } }
public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath) { #if TARGET_J2EE string fp = url; #else string fp = filePath != null?filePath.Replace(HttpRuntime.AppDomainAppPath, "/").Replace(Path.DirectorySeparatorChar, '/') : null; #endif Type type; #if NET_2_0 && !TARGET_JVM type = BuildManager.GetCompiledType(url); #else type = WebServiceParser.GetCompiledType(fp, context); #endif WSProtocol protocol = GuessProtocol(context, verb); #if NET_2_0 context.Items ["WebServiceSoapVersion"] = protocol == WSProtocol.HttpSoap12 ? SoapProtocolVersion.Soap12 : SoapProtocolVersion.Default; #endif bool supported = false; IHttpHandler handler = null; supported = WSConfig.IsSupported(protocol); if (!supported) { switch (protocol) { #if NET_2_0 default: if (((protocol & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) && (WSConfig.Current.EnabledProtocols & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) { throw new InvalidOperationException("Possible SOAP version mismatch."); } break; #endif case WSProtocol.HttpPost: if (WSConfig.IsSupported(WSProtocol.HttpPostLocalhost)) { #if NET_2_0 supported = context.Request.IsLocal; #else string localAddr = context.Request.ServerVariables ["LOCAL_ADDR"]; supported = localAddr != null && (localAddr == context.Request.ServerVariables ["REMOTE_ADDR"] || IPAddress.IsLoopback(IPAddress.Parse(localAddr))); #endif } break; } } if (!supported) { throw new InvalidOperationException("Unsupported request format."); } switch (protocol) { case WSProtocol.HttpSoap12: case WSProtocol.HttpSoap: handler = GetTypeHandler(context, new HttpSoapWebServiceHandler(type)); break; case WSProtocol.HttpPost: case WSProtocol.HttpGet: handler = GetTypeHandler(context, new HttpSimpleWebServiceHandler(type, protocol.ToString())); break; case WSProtocol.Documentation: SoapDocumentationHandler soapHandler; soapHandler = new SoapDocumentationHandler(type, context); if (soapHandler.PageHandler is IRequiresSessionState) { if (soapHandler.PageHandler is IReadOnlySessionState) { handler = new ReadOnlySessionWrapperHandler(soapHandler); } else { handler = new SessionWrapperHandler(soapHandler); } } else { handler = soapHandler; } break; } return(handler); }
public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath) { string fp = filePath != null?filePath.Replace(HttpRuntime.AppDomainAppPath, "/").Replace(Path.DirectorySeparatorChar, '/') : null; Type type; type = BuildManager.GetCompiledType(url); WSProtocol protocol = GuessProtocol(context, verb); context.Items ["WebServiceSoapVersion"] = protocol == WSProtocol.HttpSoap12 ? SoapProtocolVersion.Soap12 : SoapProtocolVersion.Default; bool supported = false; IHttpHandler handler = null; supported = WSConfig.IsSupported(protocol); if (!supported) { switch (protocol) { default: if (((protocol & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) && (WSConfig.Current.EnabledProtocols & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) { throw new InvalidOperationException("Possible SOAP version mismatch."); } break; case WSProtocol.HttpPost: if (WSConfig.IsSupported(WSProtocol.HttpPostLocalhost)) { supported = context.Request.IsLocal; } break; } } if (!supported) { throw new InvalidOperationException("Unsupported request format."); } switch (protocol) { case WSProtocol.HttpSoap12: case WSProtocol.HttpSoap: handler = GetTypeHandler(context, new HttpSoapWebServiceHandler(type)); break; case WSProtocol.HttpPost: case WSProtocol.HttpGet: handler = GetTypeHandler(context, new HttpSimpleWebServiceHandler(type, protocol.ToString())); break; case WSProtocol.Documentation: SoapDocumentationHandler soapHandler; soapHandler = new SoapDocumentationHandler(type, context); if (soapHandler.PageHandler is IRequiresSessionState) { if (soapHandler.PageHandler is IReadOnlySessionState) { handler = new ReadOnlySessionWrapperHandler(soapHandler); } else { handler = new SessionWrapperHandler(soapHandler); } } else { handler = soapHandler; } break; } return(handler); }