internal WsdlGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output) { this._typeToInteropNS = new Hashtable(); this._textWriter = output; this._queue = new Queue(); this._name = null; this._namespaces = new ArrayList(); this._dynamicAssembly = null; this._serviceEndpoint = null; for (int i = 0; i < serviceTypes.Length; i++) { if ((serviceTypes[i] != null) && (serviceTypes[i].ObjectType.BaseType != null)) { this.ProcessTypeAttributes(serviceTypes[i].ObjectType); this._queue.Enqueue(serviceTypes[i].ObjectType); } if (serviceTypes[i].Url != null) { if (this._typeToServiceEndpoint == null) { this._typeToServiceEndpoint = new Hashtable(10); } if (this._typeToServiceEndpoint.ContainsKey(serviceTypes[i].ObjectType.Name)) { ((ArrayList) this._typeToServiceEndpoint[serviceTypes[i].ObjectType.Name]).Add(serviceTypes[i].Url); } else { ArrayList list2 = new ArrayList(10); list2.Add(serviceTypes[i].Url); this._typeToServiceEndpoint[serviceTypes[i].ObjectType.Name] = list2; } } } }
} // ConvertTypesToSchemaToFile /// <include file='doc\MetaData.uex' path='docs/doc[@for="MetaData.ConvertTypesToSchemaToFile2"]/*' /> public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream) { Util.Log("MetaData.ConvertTypesToSchemaToStream 4"); TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true)); SUDSGenerator sgen = new SUDSGenerator(serviceTypes, sdlType, tw); sgen.Generate(); tw.Flush(); } // ConvertTypesToSchemaToStream
internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output) { Util.Log("SUDSGenerator.SUDSGenerator 5 "); if (sdlType == SdlType.Sdl) sdlGenerator = new SdlGenerator(serviceTypes, sdlType, output); else wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output); this.sdlType = sdlType; }
} // ConvertTypesToSchemaToFile public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream) { Util.Log("MetaData.ConvertTypesToSchemaToFile 2 "); ServiceType[] serviceTypes = new ServiceType[types.Length]; for (int i=0; i<types.Length; i++) serviceTypes[i] = new ServiceType(types[i]); ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream); } // ConvertTypesToSchemaToStream
} // ConvertTypesToSchemaToFile public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream) { Util.Log("MetaData.ConvertTypesToSchemaToStream 4"); if (sdlType == SdlType.Sdl) throw new NotSupportedException( String.Format( CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Sdl generation is not supported"))); TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true)); SUDSGenerator sgen = new SUDSGenerator(serviceTypes, sdlType, tw); sgen.Generate(); tw.Flush(); } // ConvertTypesToSchemaToStream
public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream) { ServiceType[] serviceTypes = new ServiceType[types.Length]; for (int i = 0; i < types.Length; i++) { serviceTypes[i] = new ServiceType(types[i]); } ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream); }
public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream) { if (sdlType == SdlType.Sdl) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Sdl generation is not supported"), new object[0])); } TextWriter output = new StreamWriter(outputStream, new UTF8Encoding(false, true)); new SUDSGenerator(serviceTypes, sdlType, output).Generate(); output.Flush(); }
public static void ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, string path) { ConvertTypesToSchemaToStream(types, sdlType, System.IO.File.Create(path)); }
internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output) { this.wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output); this.sdlType = sdlType; }
public static void ConvertTypesToSchemaToStream (Type [] types, SdlType sdlType, Stream outputStream) { ServiceType[] st = new ServiceType [types.Length]; for (int n=0; n<types.Length; n++) st [n] = new ServiceType (types[n]); ConvertTypesToSchemaToStream (st, sdlType, outputStream); }
void FindTypes (ServiceType[] servicetypes, Hashtable dataTypes, ArrayList services) { ArrayList mbrTypes = new ArrayList(); foreach (ServiceType st in servicetypes) FindDataTypes (st.ObjectType, null, dataTypes, mbrTypes); foreach (Type mbrType in mbrTypes) { ServiceType stFound = null; foreach (ServiceType st in servicetypes) if (mbrType == st.ObjectType) stFound = st; if (stFound != null) services.Add (stFound); else services.Add (new ServiceType (mbrType)); } }
ArrayList FindServices (ServiceType[] servicetypes) { ArrayList list = new ArrayList (); foreach (ServiceType st in servicetypes) if (IsService (st.ObjectType)) list.Add (st); return list; }
public void ExportTypes (ServiceType[] servicetypes, SdlType sdltype, XmlTextWriter tw) { if (sdltype == SdlType.Sdl) // Obsolete, we don't support this throw new NotSupportedException (); if (servicetypes.Length == 0) return; Type maint = servicetypes [0].ObjectType; Hashtable dataTypes = new Hashtable (); ArrayList services = new ArrayList (); FindTypes (servicetypes, dataTypes, services); if (services.Count > 0) maint = ((ServiceType) services[0]).ObjectType; string serviceNs = GetXmlNamespace (maint, null); tw.Formatting = Formatting.Indented; tw.WriteStartElement ("definitions", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", maint.Name); tw.WriteAttributeString ("targetNamespace", serviceNs); tw.WriteAttributeString ("xmlns", MetaData.XmlnsNamespace, MetaData.WsdlNamespace); tw.WriteAttributeString ("xmlns", "tns", MetaData.XmlnsNamespace, serviceNs); tw.WriteAttributeString ("xmlns", "xsd", MetaData.XmlnsNamespace, MetaData.SchemaNamespace); tw.WriteAttributeString ("xmlns", "xsi", MetaData.XmlnsNamespace, MetaData.SchemaInstanceNamespace); tw.WriteAttributeString ("xmlns", "suds", MetaData.XmlnsNamespace, MetaData.SudsNamespace); tw.WriteAttributeString ("xmlns", "wsdl", MetaData.XmlnsNamespace, MetaData.WsdlNamespace); tw.WriteAttributeString ("xmlns", "soapenc", MetaData.XmlnsNamespace, MetaData.SoapEncodingNamespace); tw.WriteAttributeString ("xmlns", "soap", MetaData.XmlnsNamespace, MetaData.SoapNamespace); int nums = 0; foreach (DictionaryEntry entry in dataTypes) { string ns = (string) entry.Key; if (tw.LookupPrefix (ns) != null) continue; tw.WriteAttributeString ("xmlns", "ns"+nums, MetaData.XmlnsNamespace, ns); nums++; } // Schema if (dataTypes.Count > 0) { tw.WriteStartElement ("types", MetaData.WsdlNamespace); foreach (DictionaryEntry entry in dataTypes) { SchemaInfo sinfo = (SchemaInfo) entry.Value; if (sinfo == null || sinfo.Types.Count == 0) continue; tw.WriteStartElement ("s", "schema", MetaData.SchemaNamespace); tw.WriteAttributeString ("targetNamespace", (string) entry.Key); tw.WriteAttributeString ("elementFormDefault", "unqualified"); tw.WriteAttributeString ("attributeFormDefault", "unqualified"); foreach (string ns in sinfo.Imports) { if (ns == (string) entry.Key) continue; tw.WriteStartElement ("import", MetaData.SchemaNamespace); tw.WriteAttributeString ("namespace", ns); tw.WriteEndElement (); } foreach (Type type in sinfo.Types) WriteDataTypeSchema (tw, type); tw.WriteEndElement (); } tw.WriteEndElement (); } // Bindings /* foreach (ServiceType st in servicetypes) WriteServiceBinding (tw, st); */ foreach (ServiceType st in services) WriteServiceBinding (tw, st, dataTypes); // Service element tw.WriteStartElement ("service", MetaData.WsdlNamespace); if (services.Count > 0) tw.WriteAttributeString ("name", GetServiceName (maint)); else tw.WriteAttributeString ("name", "Service"); foreach (ServiceType st in services) { WriteServiceType (tw, st); } tw.WriteEndElement (); // Closing tw.WriteEndElement (); tw.Flush (); }
void WriteServiceBinding (XmlTextWriter tw, ServiceType st, Hashtable dataTypes) { Type type = st.ObjectType; string typeName = type.Name; MethodInfo[] mets = type.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); bool isService = IsService (type); // Messages if (isService) { foreach (MethodInfo met in mets) { if (met.DeclaringType.Assembly == typeof(object).Assembly) continue; ParameterInfo[] pars = met.GetParameters (); tw.WriteStartElement ("message", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", typeName + "." + met.Name + "Input"); foreach (ParameterInfo par in pars) { if (!par.ParameterType.IsByRef) WritePart (tw, par.Name, par.ParameterType, type); } tw.WriteEndElement (); // message tw.WriteStartElement ("message", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", typeName + "." + met.Name + "Output"); if (met.ReturnType != typeof(void)) WritePart (tw, "return", met.ReturnType, type); foreach (ParameterInfo par in pars) { if (par.ParameterType.IsByRef || par.IsOut) WritePart (tw, par.Name, par.ParameterType, type); } tw.WriteEndElement (); // message } } // Port type tw.WriteStartElement ("portType", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", typeName + "PortType"); if (isService) { foreach (MethodInfo met in mets) { if (met.DeclaringType.Assembly == typeof(object).Assembly) continue; tw.WriteStartElement ("operation", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", met.Name); StringBuilder sb = new StringBuilder (); ParameterInfo[] pars = met.GetParameters (); foreach (ParameterInfo par in pars) { if (sb.Length != 0) sb.Append (" "); sb.Append (par.Name); } tw.WriteAttributeString ("parameterOrder", sb.ToString ()); tw.WriteStartElement ("input", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", met.Name + "Request"); tw.WriteAttributeString ("message", "tns:" + typeName + "." + met.Name + "Input"); tw.WriteEndElement (); tw.WriteStartElement ("output", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", met.Name + "Response"); tw.WriteAttributeString ("message", "tns:" + typeName + "." + met.Name + "Output"); tw.WriteEndElement (); tw.WriteEndElement (); // operation } } tw.WriteEndElement (); // portType // Binding tw.WriteStartElement ("binding", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", typeName + "Binding"); tw.WriteAttributeString ("type", "tns:" + typeName + "PortType"); tw.WriteStartElement ("soap", "binding", MetaData.SoapNamespace); tw.WriteAttributeString ("style", "rpc"); tw.WriteAttributeString ("transport", "http://schemas.xmlsoap.org/soap/http"); tw.WriteEndElement (); WriteTypeSuds (tw, type); SchemaInfo sinfo = (SchemaInfo) dataTypes [GetXmlNamespace (type,null)]; if (sinfo != null && !sinfo.SudsGenerated) { foreach (Type dt in sinfo.Types) WriteTypeSuds (tw, dt); sinfo.SudsGenerated = true; } if (isService) { foreach (MethodInfo met in mets) { if (met.DeclaringType.Assembly == typeof(object).Assembly) continue; tw.WriteStartElement ("operation", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", met.Name); tw.WriteStartElement ("soap", "operation", MetaData.SoapNamespace); tw.WriteAttributeString ("soapAction", GetSoapAction (met)); tw.WriteEndElement (); tw.WriteStartElement ("suds", "method", MetaData.SudsNamespace); tw.WriteAttributeString ("attributes", "public"); tw.WriteEndElement (); tw.WriteStartElement ("input", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", met.Name + "Request"); WriteMessageBindingBody (tw, type); tw.WriteEndElement (); tw.WriteStartElement ("output", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", met.Name + "Response"); WriteMessageBindingBody (tw, type); tw.WriteEndElement (); tw.WriteEndElement (); // operation } } tw.WriteEndElement (); // binding }
void WriteServiceType (XmlTextWriter tw, ServiceType st) { tw.WriteStartElement ("port", MetaData.WsdlNamespace); tw.WriteAttributeString ("name", GetPortName (st.ObjectType)); tw.WriteAttributeString ("binding", "tns:" + GetBindingName (st.ObjectType)); if (st.Url != null) { tw.WriteStartElement ("soap","address", MetaData.SoapNamespace); tw.WriteAttributeString ("location", st.Url); tw.WriteEndElement (); } tw.WriteEndElement (); }
public static void ConvertTypesToSchemaToStream (ServiceType [] serviceTypes, SdlType sdlType, Stream outputStream) { MetaDataExporter exporter = new MetaDataExporter (); MemoryStream memStream = new MemoryStream (); StreamWriter sw = new StreamWriter (memStream); XmlTextWriter tw = new XmlTextWriter (sw); exporter.ExportTypes (serviceTypes, sdlType, tw); tw.Flush (); memStream.Position = 0; CopyStream (memStream, outputStream); }
public ServerProcessing ProcessMessage (IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { responseMsg = null; responseStream = null; responseHeaders = null; string verb = requestHeaders [CommonTransportKeys.RequestVerb] as string; string uri = (string) requestHeaders [CommonTransportKeys.RequestUri]; if (verb == "GET" && uri.EndsWith ("?wsdl")) { try { uri = uri.Substring (0, uri.Length - 5); Type type = RemotingServices.GetServerTypeForUri (uri); string url = _channel.GetUrlsForUri (uri)[0]; ServiceType st = new ServiceType (type, url); responseStream = new MemoryStream (); MetaData.ConvertTypesToSchemaToStream (new ServiceType[] {st}, SdlType.Wsdl, responseStream); responseStream.Position = 0; responseMsg = null; responseHeaders = new TransportHeaders (); responseHeaders [CommonTransportKeys.ContentType] = "text/xml"; } catch (Exception ex) { responseHeaders = new TransportHeaders (); responseHeaders [CommonTransportKeys.HttpStatusCode] = "400"; responseStream = new MemoryStream (Encoding.UTF8.GetBytes (ex.ToString ())); } return ServerProcessing.Complete; } else return _next.ProcessMessage (sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream); }
} // ConvertTypesToSchemaToStream public static void ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, String path) { Util.Log("MetaData.ConvertTypesToSchemaToFile 3 "+path); ConvertTypesToSchemaToStream(types, sdlType, File.Create(path)); } // ConvertTypesToSchemaToFile
} // ShouldIntercept private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream) { if (!MetadataEnabled) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled")); } String requestUri = requestHeaders[CommonTransportKeys.RequestUri] as String; String objectUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri); if (!RemoteApplicationMetadataEnabled && (String.Compare(objectUri, "RemoteApplicationMetadata.rem", true, CultureInfo.InvariantCulture) == 0)) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled")); } // If the host header is present, we will use this in the generated uri's String hostName = (String)requestHeaders["Host"]; if (hostName != null) { // filter out port number if present int index = hostName.IndexOf(':'); if (index != -1) { hostName = hostName.Substring(0, index); } } // For IIS, we will bash the scheme://hostname:port with the incoming value String iisHostOverride = null; HttpContext context = HttpContext.Current; if (context != null) { HttpRequest request = context.Request; String scheme = null; if (request.IsSecureConnection) { scheme = "https"; } else { scheme = "http"; } int port = context.Request.Url.Port; StringBuilder sb = new StringBuilder(100); sb.Append(scheme); sb.Append("://"); if (hostName != null) { sb.Append(hostName); } else { sb.Append(CoreChannel.GetMachineName()); } sb.Append(":"); sb.Append(port.ToString()); iisHostOverride = sb.ToString(); } ServiceType[] types = null; if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", true, CultureInfo.InvariantCulture) == 0) { // get the service description for all registered service types ActivatedServiceTypeEntry[] activatedTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes(); WellKnownServiceTypeEntry[] wellKnownTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // determine total number of types int typeCount = 0; if (activatedTypes != null) { typeCount += activatedTypes.Length; } if (wellKnownTypes != null) { typeCount += wellKnownTypes.Length; } types = new ServiceType[typeCount]; // collect data int co = 0; if (activatedTypes != null) { foreach (ActivatedServiceTypeEntry entry in activatedTypes) { types[co++] = new ServiceType(entry.ObjectType, null); } } if (wellKnownTypes != null) { foreach (WellKnownServiceTypeEntry entry in wellKnownTypes) { String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri); String url = urls[0]; if (iisHostOverride != null) { url = HttpChannelHelper.ReplaceChannelUriWithThisString(url, iisHostOverride); } else if (hostName != null) { url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); } types[co++] = new ServiceType(entry.ObjectType, url); } } InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed."); } else { // get the service description for a particular object Type objectType = RemotingServices.GetServerTypeForUri(objectUri); if (objectType == null) { throw new RemotingException( String.Format( "Object with uri '{0}' does not exist at server.", objectUri)); } String[] urls = _receiver.GetUrlsForUri(objectUri); String url = urls[0]; if (iisHostOverride != null) { url = HttpChannelHelper.ReplaceChannelUriWithThisString(url, iisHostOverride); } else if (hostName != null) { url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); } types = new ServiceType[1]; types[0] = new ServiceType(objectType, url); } responseHeaders["Content-Type"] = "text/xml"; bool bMemStream = false; outputStream = sinkStack.GetResponseStream(null, responseHeaders); if (outputStream == null) { outputStream = new MemoryStream(1024); bMemStream = true; } MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream); if (bMemStream) { outputStream.Position = 0; } } // GenerateXmlForUri
} // ShouldIntercept private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream) { if (!MetadataEnabled) throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled")); String requestUri = requestHeaders[CommonTransportKeys.RequestUri] as String; String objectUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri); if (!RemoteApplicationMetadataEnabled && (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)) throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled")); // If the host header is present, we will use this in the generated uri's String hostName = (String)requestHeaders["Host"]; if (hostName != null) { // filter out port number if present int index = hostName.IndexOf(':'); if (index != -1) hostName = hostName.Substring(0, index); } ServiceType[] types = null; if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { // get the service description for all registered service types ActivatedServiceTypeEntry[] activatedTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes(); WellKnownServiceTypeEntry[] wellKnownTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // determine total number of types int typeCount = 0; if (activatedTypes != null) typeCount += activatedTypes.Length; if (wellKnownTypes != null) typeCount += wellKnownTypes.Length; types = new ServiceType[typeCount]; // collect data int co = 0; if (activatedTypes != null) { foreach (ActivatedServiceTypeEntry entry in activatedTypes) { types[co++] = new ServiceType(entry.ObjectType, null); } } if (wellKnownTypes != null) { foreach (WellKnownServiceTypeEntry entry in wellKnownTypes) { String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri); String url = urls[0]; if (hostName != null) url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); types[co++] = new ServiceType(entry.ObjectType, url); } } InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed."); } else { // get the service description for a particular object Type objectType = RemotingServices.GetServerTypeForUri(objectUri); if (objectType == null) { throw new RemotingException( String.Format( CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", objectUri)); } String[] urls = _receiver.GetUrlsForUri(objectUri); String url = urls[0]; if (hostName != null) url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); types = new ServiceType[1]; types[0] = new ServiceType(objectType, url); } responseHeaders["Content-Type"] = "text/xml"; bool bMemStream = false; outputStream = sinkStack.GetResponseStream(null, responseHeaders); if (outputStream == null) { outputStream = new MemoryStream(1024); bMemStream = true; } MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream); if (bMemStream) outputStream.Position = 0; } // GenerateXmlForUri
public static void ConvertTypesToSchemaToFile (ServiceType [] types, SdlType sdlType, string path) { FileStream fs = new FileStream (path, FileMode.Create, FileAccess.Write); ConvertTypesToSchemaToStream (types, sdlType, fs); fs.Close (); }
internal WsdlGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output) { Util.Log("WsdlGenerator.WsdlGenerator 5 "); _textWriter = output; _queue = new Queue(); _name = null; _namespaces = new ArrayList(); _dynamicAssembly = null; _serviceEndpoint = null; for (int i=0; i<serviceTypes.Length; i++) { if (serviceTypes[i] != null) { if (serviceTypes[i].ObjectType.BaseType != null) { Util.Log("WsdlGenerator.WsdlGenerator ProcessTypeAttributes 3 objectType "+serviceTypes[i].ObjectType+" basetype "+serviceTypes[i].ObjectType.BaseType); ProcessTypeAttributes(serviceTypes[i].ObjectType); _queue.Enqueue(serviceTypes[i].ObjectType); } } // Associate serviceEndpoint with type. A type can have multiple serviceEndpoints if (serviceTypes[i].Url != null) { if (_typeToServiceEndpoint == null) _typeToServiceEndpoint = new Hashtable(10); if (_typeToServiceEndpoint.ContainsKey(serviceTypes[i].ObjectType.Name)) { ArrayList serviceEndpoints = (ArrayList)_typeToServiceEndpoint[serviceTypes[i].ObjectType.Name]; serviceEndpoints.Add(serviceTypes[i].Url); } else { ArrayList serviceEndpoints = new ArrayList(10); serviceEndpoints.Add(serviceTypes[i].Url); _typeToServiceEndpoint[serviceTypes[i].ObjectType.Name] = serviceEndpoints; } } } }
private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream) { if (!this.MetadataEnabled) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled")); } string uri = requestHeaders["__RequestUri"] as string; string objectUriFromRequestUri = HttpChannelHelper.GetObjectUriFromRequestUri(uri); if (!this.RemoteApplicationMetadataEnabled && (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled")); } string hostName = (string) requestHeaders["Host"]; if (hostName != null) { int index = hostName.IndexOf(':'); if (index != -1) { hostName = hostName.Substring(0, index); } } string channelUri = SetupUrlBashingForIisIfNecessary(hostName); ServiceType[] serviceTypes = null; if (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { ActivatedServiceTypeEntry[] registeredActivatedServiceTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes(); WellKnownServiceTypeEntry[] registeredWellKnownServiceTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); int num2 = 0; if (registeredActivatedServiceTypes != null) { num2 += registeredActivatedServiceTypes.Length; } if (registeredWellKnownServiceTypes != null) { num2 += registeredWellKnownServiceTypes.Length; } serviceTypes = new ServiceType[num2]; int num3 = 0; if (registeredActivatedServiceTypes != null) { foreach (ActivatedServiceTypeEntry entry in registeredActivatedServiceTypes) { serviceTypes[num3++] = new ServiceType(entry.ObjectType, null); } } if (registeredWellKnownServiceTypes != null) { foreach (WellKnownServiceTypeEntry entry2 in registeredWellKnownServiceTypes) { string url = this._receiver.GetUrlsForUri(entry2.ObjectUri)[0]; if (channelUri != null) { url = HttpChannelHelper.ReplaceChannelUriWithThisString(url, channelUri); } else if (hostName != null) { url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); } serviceTypes[num3++] = new ServiceType(entry2.ObjectType, url); } } } else { Type serverTypeForUri = RemotingServices.GetServerTypeForUri(objectUriFromRequestUri); if (serverTypeForUri == null) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", new object[] { objectUriFromRequestUri })); } string str6 = this._receiver.GetUrlsForUri(objectUriFromRequestUri)[0]; if (channelUri != null) { str6 = HttpChannelHelper.ReplaceChannelUriWithThisString(str6, channelUri); } else if (hostName != null) { str6 = HttpChannelHelper.ReplaceMachineNameWithThisString(str6, hostName); } serviceTypes = new ServiceType[] { new ServiceType(serverTypeForUri, str6) }; } responseHeaders["Content-Type"] = "text/xml"; bool flag = false; outputStream = sinkStack.GetResponseStream(null, responseHeaders); if (outputStream == null) { outputStream = new MemoryStream(0x400); flag = true; } MetaData.ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream); if (flag) { outputStream.Position = 0L; } }