/// <include file='doc\SchemaReference.uex' path='docs/doc[@for="SchemaReference.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); } XmlSchema schema = ClientProtocol.Documents[Url] as XmlSchema; if (schema == null) { schema = XmlSchema.Read(stream, null); ClientProtocol.Documents[Url] = schema; } ClientProtocol.References[Url] = this; // now resolve references in the schema. foreach (object item in schema.Includes) { string location = null; try { if (item is XmlSchemaInclude) { location = ((XmlSchemaInclude)item).SchemaLocation; if (location == null) { continue; } location = new Uri(new Uri(Url), location).ToString(); SchemaReference includeRef = new SchemaReference(location); includeRef.ClientProtocol = ClientProtocol; ClientProtocol.References[location] = includeRef; includeRef.Resolve(); } else if (item is XmlSchemaImport) { location = ((XmlSchemaImport)item).SchemaLocation; if (location == null) { continue; } location = new Uri(new Uri(Url), location).ToString(); SchemaReference importRef = new SchemaReference(location); importRef.ClientProtocol = ClientProtocol; ClientProtocol.References[location] = importRef; importRef.Resolve(); } } catch (Exception e) { throw new InvalidDocumentContentsException(Res.GetString(Res.TheSchemaDocumentContainsLinksThatCouldNotBeResolved, location), e); } } return; }
protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) { base.ClientProtocol.Errors[this.Url] = new InvalidContentTypeException(System.Web.Services.Res.GetString("WebInvalidContentType", new object[] { contentType }), contentType); } XmlSchema schema = base.ClientProtocol.Documents[this.Url] as XmlSchema; if (schema == null) { if (base.ClientProtocol.Errors[this.Url] != null) { throw base.ClientProtocol.Errors[this.Url]; } schema = (XmlSchema)this.ReadDocument(stream); base.ClientProtocol.Documents[this.Url] = schema; } if (base.ClientProtocol.References[this.Url] != this) { base.ClientProtocol.References[this.Url] = this; } foreach (XmlSchemaExternal external in schema.Includes) { string url = null; try { if ((external.SchemaLocation != null) && (external.SchemaLocation.Length > 0)) { url = DiscoveryReference.UriToString(this.Url, external.SchemaLocation); SchemaReference reference = new SchemaReference(url) { ClientProtocol = base.ClientProtocol }; base.ClientProtocol.References[url] = reference; reference.Resolve(); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } throw new InvalidDocumentContentsException(System.Web.Services.Res.GetString("TheSchemaDocumentContainsLinksThatCouldNotBeResolved", new object[] { url }), exception); } } }
/// <include file='doc\SchemaReference.uex' path='docs/doc[@for="SchemaReference.Resolve"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) { ClientProtocol.Errors[Url] = new InvalidContentTypeException(Res.GetString(Res.WebInvalidContentType, contentType), contentType); } XmlSchema schema = ClientProtocol.Documents[Url] as XmlSchema; if (schema == null) { if (ClientProtocol.Errors[Url] != null) { throw (Exception)ClientProtocol.Errors[Url]; } schema = (XmlSchema)ReadDocument(stream); ClientProtocol.Documents[Url] = schema; } if (ClientProtocol.References[Url] != this) { ClientProtocol.References[Url] = this; } // now resolve references in the schema. foreach (XmlSchemaExternal external in schema.Includes) { string location = null; try { if (external.SchemaLocation != null && external.SchemaLocation.Length > 0) { location = UriToString(Url, external.SchemaLocation); SchemaReference externalRef = new SchemaReference(location); externalRef.ClientProtocol = ClientProtocol; ClientProtocol.References[location] = externalRef; externalRef.Resolve(); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } throw new InvalidDocumentContentsException(Res.GetString(Res.TheSchemaDocumentContainsLinksThatCouldNotBeResolved, location), e); } } return; }
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\SchemaReference.uex' path='docs/doc[@for="SchemaReference.Resolve"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) ClientProtocol.Errors[Url] = new InvalidContentTypeException(Res.GetString(Res.WebInvalidContentType, contentType), contentType); XmlSchema schema = ClientProtocol.Documents[Url] as XmlSchema; if ( schema == null ) { if (ClientProtocol.Errors[Url] != null) throw (Exception)ClientProtocol.Errors[Url]; schema = (XmlSchema)ReadDocument(stream); ClientProtocol.Documents[Url] = schema; } if (ClientProtocol.References[Url] != this) ClientProtocol.References[Url] = this; // now resolve references in the schema. foreach (XmlSchemaExternal external in schema.Includes) { string location = null; try { if (external.SchemaLocation != null && external.SchemaLocation.Length > 0) { location = UriToString(Url, external.SchemaLocation); SchemaReference externalRef = new SchemaReference(location); externalRef.ClientProtocol = ClientProtocol; ClientProtocol.References[location] = externalRef; externalRef.Resolve(); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } throw new InvalidDocumentContentsException(Res.GetString(Res.TheSchemaDocumentContainsLinksThatCouldNotBeResolved, location), e); } } return; }
protected internal override void Resolve(string contentType, Stream stream) { if (ContentType.IsHtml(contentType)) { base.ClientProtocol.Errors[this.Url] = new InvalidContentTypeException(System.Web.Services.Res.GetString("WebInvalidContentType", new object[] { contentType }), contentType); } XmlSchema schema = base.ClientProtocol.Documents[this.Url] as XmlSchema; if (schema == null) { if (base.ClientProtocol.Errors[this.Url] != null) { throw base.ClientProtocol.Errors[this.Url]; } schema = (XmlSchema) this.ReadDocument(stream); base.ClientProtocol.Documents[this.Url] = schema; } if (base.ClientProtocol.References[this.Url] != this) { base.ClientProtocol.References[this.Url] = this; } foreach (XmlSchemaExternal external in schema.Includes) { string url = null; try { if ((external.SchemaLocation != null) && (external.SchemaLocation.Length > 0)) { url = DiscoveryReference.UriToString(this.Url, external.SchemaLocation); SchemaReference reference = new SchemaReference(url) { ClientProtocol = base.ClientProtocol }; base.ClientProtocol.References[url] = reference; reference.Resolve(); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } throw new InvalidDocumentContentsException(System.Web.Services.Res.GetString("TheSchemaDocumentContainsLinksThatCouldNotBeResolved", new object[] { url }), exception); } } }
/// <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); } } }