protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) { throw new InvalidContentTypeException(System.Web.Services.Res.GetString("WebInvalidContentType", new object[] { contentType }), contentType); } ServiceDescription description = base.ClientProtocol.Documents[this.Url] as ServiceDescription; if (description == null) { description = ServiceDescription.Read(stream, true); description.RetrievalUrl = this.Url; base.ClientProtocol.Documents[this.Url] = description; } base.ClientProtocol.References[this.Url] = this; ArrayList list = new ArrayList(); foreach (Import import in description.Imports) { if (import.Location != null) { list.Add(import.Location); } } foreach (XmlSchema schema in description.Types.Schemas) { foreach (XmlSchemaExternal external in schema.Includes) { if ((external.SchemaLocation != null) && (external.SchemaLocation.Length > 0)) { list.Add(external.SchemaLocation); } } } foreach (string str in list) { string url = DiscoveryReference.UriToString(this.Url, str); if (base.ClientProtocol.Documents[url] == null) { string str3 = url; try { stream = base.ClientProtocol.Download(ref url, ref contentType); try { if (base.ClientProtocol.Documents[url] == null) { XmlTextReader reader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))) { WhitespaceHandling = WhitespaceHandling.Significant, XmlResolver = null, DtdProcessing = DtdProcessing.Prohibit }; if (ServiceDescription.CanRead(reader)) { ServiceDescription description2 = ServiceDescription.Read(reader, true); description2.RetrievalUrl = url; base.ClientProtocol.Documents[url] = description2; ContractReference reference = new ContractReference(url, null) { ClientProtocol = base.ClientProtocol }; try { reference.Resolve(contentType, stream); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } reference.Url = str3; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", exception); } } } else if (reader.IsStartElement("schema", "http://www.w3.org/2001/XMLSchema")) { base.ClientProtocol.Documents[url] = XmlSchema.Read(reader, null); SchemaReference reference2 = new SchemaReference(url) { ClientProtocol = base.ClientProtocol }; try { reference2.Resolve(contentType, stream); } catch (Exception exception2) { if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException)) { throw; } reference2.Url = str3; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", exception2); } } } } } finally { stream.Close(); } } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } throw new InvalidDocumentContentsException(System.Web.Services.Res.GetString("TheWSDLDocumentContainsLinksThatCouldNotBeResolved", new object[] { url }), exception3); } } } }
/// <include file='doc\ContractReference.uex' path='docs/doc[@for="ContractReference.Resolve"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) throw new InvalidContentTypeException(Res.GetString(Res.WebInvalidContentType, contentType), contentType); ServiceDescription serviceDescription = ClientProtocol.Documents[Url] as ServiceDescription; if ( serviceDescription == null ) { serviceDescription = ServiceDescription.Read(stream, true); serviceDescription.RetrievalUrl = Url; ClientProtocol.Documents[Url] = serviceDescription; } ClientProtocol.References[Url] = this; ArrayList importUrls = new ArrayList(); foreach (Import import in serviceDescription.Imports) if (import.Location != null) importUrls.Add(import.Location); foreach (XmlSchema schema in serviceDescription.Types.Schemas) { foreach (XmlSchemaExternal external in schema.Includes) { if (external.SchemaLocation != null && external.SchemaLocation.Length > 0) { importUrls.Add(external.SchemaLocation); } } } foreach (string urlFromImport in importUrls) { // make the (possibly) relative Uri in the contract fully qualified with respect to the contract URL string importUrl = UriToString(Url, urlFromImport); if ( ClientProtocol.Documents[importUrl] != null ) { continue; } string oldUrl = importUrl; try { stream = ClientProtocol.Download(ref importUrl, ref contentType); try { //Proceed only if not been here before if ( ClientProtocol.Documents[importUrl] == null ) { XmlTextReader reader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))); reader.WhitespaceHandling = WhitespaceHandling.Significant; reader.XmlResolver = null; reader.DtdProcessing = DtdProcessing.Prohibit; //Resolve on WSDL and XSD will go recursivelly if (ServiceDescription.CanRead(reader)) { ServiceDescription doc = ServiceDescription.Read(reader, true); doc.RetrievalUrl = importUrl; ClientProtocol.Documents[importUrl] = doc; ContractReference contractReference = new ContractReference(importUrl, null); contractReference.ClientProtocol = ClientProtocol; try { contractReference.Resolve(contentType, stream); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } contractReference.Url = oldUrl; if (Tracing.On) Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", e); } } else if (reader.IsStartElement("schema", XmlSchema.Namespace)) { ClientProtocol.Documents[importUrl] = XmlSchema.Read(reader, null); SchemaReference schemaReference = new SchemaReference(importUrl); schemaReference.ClientProtocol = ClientProtocol; try { schemaReference.Resolve(contentType, stream); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } schemaReference.Url = oldUrl; if (Tracing.On) Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", e); } } // If it's not XML, or we don't know what kind of XML it is, skip the file. The user // will have to download the dependent file(s) manually, but at least we will continue // to discover files instead of throwing an exception. } } finally { stream.Close(); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } throw new InvalidDocumentContentsException(Res.GetString(Res.TheWSDLDocumentContainsLinksThatCouldNotBeResolved, importUrl), e); } } }
/// <include file='doc\ContractReference.uex' path='docs/doc[@for="ContractReference.Resolve"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) { throw new InvalidContentTypeException(Res.GetString(Res.WebInvalidContentType, contentType), contentType); } ServiceDescription serviceDescription = ClientProtocol.Documents[Url] as ServiceDescription; if (serviceDescription == null) { serviceDescription = ServiceDescription.Read(stream, true); serviceDescription.RetrievalUrl = Url; ClientProtocol.Documents[Url] = serviceDescription; } ClientProtocol.References[Url] = this; ArrayList importUrls = new ArrayList(); foreach (Import import in serviceDescription.Imports) { if (import.Location != null) { importUrls.Add(import.Location); } } foreach (XmlSchema schema in serviceDescription.Types.Schemas) { foreach (XmlSchemaExternal external in schema.Includes) { if (external.SchemaLocation != null && external.SchemaLocation.Length > 0) { importUrls.Add(external.SchemaLocation); } } } foreach (string urlFromImport in importUrls) { // make the (possibly) relative Uri in the contract fully qualified with respect to the contract URL string importUrl = UriToString(Url, urlFromImport); if (ClientProtocol.Documents[importUrl] != null) { continue; } string oldUrl = importUrl; try { stream = ClientProtocol.Download(ref importUrl, ref contentType); try { //Proceed only if not been here before if (ClientProtocol.Documents[importUrl] == null) { XmlTextReader reader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))); reader.WhitespaceHandling = WhitespaceHandling.Significant; reader.XmlResolver = null; reader.DtdProcessing = DtdProcessing.Prohibit; //Resolve on WSDL and XSD will go recursivelly if (ServiceDescription.CanRead(reader)) { ServiceDescription doc = ServiceDescription.Read(reader, true); doc.RetrievalUrl = importUrl; ClientProtocol.Documents[importUrl] = doc; ContractReference contractReference = new ContractReference(importUrl, null); contractReference.ClientProtocol = ClientProtocol; try { contractReference.Resolve(contentType, stream); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } contractReference.Url = oldUrl; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", e); } } } else if (reader.IsStartElement("schema", XmlSchema.Namespace)) { ClientProtocol.Documents[importUrl] = XmlSchema.Read(reader, null); SchemaReference schemaReference = new SchemaReference(importUrl); schemaReference.ClientProtocol = ClientProtocol; try { schemaReference.Resolve(contentType, stream); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } schemaReference.Url = oldUrl; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", e); } } } // If it's not XML, or we don't know what kind of XML it is, skip the file. The user // will have to download the dependent file(s) manually, but at least we will continue // to discover files instead of throwing an exception. } } finally { stream.Close(); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } throw new InvalidDocumentContentsException(Res.GetString(Res.TheWSDLDocumentContainsLinksThatCouldNotBeResolved, importUrl), e); } } }
protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) { throw new InvalidContentTypeException(System.Web.Services.Res.GetString("WebInvalidContentType", new object[] { contentType }), contentType); } ServiceDescription description = base.ClientProtocol.Documents[this.Url] as ServiceDescription; if (description == null) { description = ServiceDescription.Read(stream, true); description.RetrievalUrl = this.Url; base.ClientProtocol.Documents[this.Url] = description; } base.ClientProtocol.References[this.Url] = this; ArrayList list = new ArrayList(); foreach (Import import in description.Imports) { if (import.Location != null) { list.Add(import.Location); } } foreach (XmlSchema schema in description.Types.Schemas) { foreach (XmlSchemaExternal external in schema.Includes) { if ((external.SchemaLocation != null) && (external.SchemaLocation.Length > 0)) { list.Add(external.SchemaLocation); } } } foreach (string str in list) { string url = DiscoveryReference.UriToString(this.Url, str); if (base.ClientProtocol.Documents[url] == null) { string str3 = url; try { stream = base.ClientProtocol.Download(ref url, ref contentType); try { if (base.ClientProtocol.Documents[url] == null) { XmlTextReader reader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))) { WhitespaceHandling = WhitespaceHandling.Significant, XmlResolver = null, DtdProcessing = DtdProcessing.Prohibit }; if (ServiceDescription.CanRead(reader)) { ServiceDescription description2 = ServiceDescription.Read(reader, true); description2.RetrievalUrl = url; base.ClientProtocol.Documents[url] = description2; ContractReference reference = new ContractReference(url, null) { ClientProtocol = base.ClientProtocol }; try { reference.Resolve(contentType, stream); } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } reference.Url = str3; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", exception); } } } else if (reader.IsStartElement("schema", "http://www.w3.org/2001/XMLSchema")) { base.ClientProtocol.Documents[url] = XmlSchema.Read(reader, null); SchemaReference reference2 = new SchemaReference(url) { ClientProtocol = base.ClientProtocol }; try { reference2.Resolve(contentType, stream); } catch (Exception exception2) { if (((exception2 is ThreadAbortException) || (exception2 is StackOverflowException)) || (exception2 is OutOfMemoryException)) { throw; } reference2.Url = str3; if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, this, "Resolve", exception2); } } } } } finally { stream.Close(); } } catch (Exception exception3) { if (((exception3 is ThreadAbortException) || (exception3 is StackOverflowException)) || (exception3 is OutOfMemoryException)) { throw; } throw new InvalidDocumentContentsException(System.Web.Services.Res.GetString("TheWSDLDocumentContainsLinksThatCouldNotBeResolved", new object[] { url }), exception3); } } } }