/// <include file='doc\DiscoveryDocumentReference.uex' path='docs/doc[@for="DiscoveryDocumentReference.GetDocumentNoParse"]/*' /> /// <devdoc> /// Retrieves a discovery document from Url, either out of the ClientProtocol /// or from a stream. Does not /// </devdoc> private static DiscoveryDocument GetDocumentNoParse(ref string url, DiscoveryClientProtocol client) { DiscoveryDocument d = (DiscoveryDocument)client.Documents[url]; if (d != null) { return(d); } string contentType = null; Stream stream = client.Download(ref url, ref contentType); try { XmlTextReader reader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))); reader.WhitespaceHandling = WhitespaceHandling.Significant; reader.XmlResolver = null; reader.DtdProcessing = DtdProcessing.Prohibit; if (!DiscoveryDocument.CanRead(reader)) { // there is no discovery document at this location ArgumentException exception = new ArgumentException(Res.GetString(Res.WebInvalidFormat)); throw new InvalidOperationException(Res.GetString(Res.WebMissingDocument, url), exception); } return(DiscoveryDocument.Read(reader)); } finally { stream.Close(); } }
private static DiscoveryDocument GetDocumentNoParse(ref string url, DiscoveryClientProtocol client) { DiscoveryDocument document2; DiscoveryDocument document = (DiscoveryDocument) client.Documents[url]; if (document != null) { return document; } string contentType = null; Stream stream = client.Download(ref url, ref contentType); try { XmlTextReader xmlReader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))) { WhitespaceHandling = WhitespaceHandling.Significant, XmlResolver = null, DtdProcessing = DtdProcessing.Prohibit }; if (!DiscoveryDocument.CanRead(xmlReader)) { ArgumentException innerException = new ArgumentException(System.Web.Services.Res.GetString("WebInvalidFormat")); throw new InvalidOperationException(System.Web.Services.Res.GetString("WebMissingDocument", new object[] { url }), innerException); } document2 = DiscoveryDocument.Read(xmlReader); } finally { stream.Close(); } return document2; }
private static DiscoveryDocument GetDocumentNoParse(ref string url, DiscoveryClientProtocol client) { DiscoveryDocument document2; DiscoveryDocument document = (DiscoveryDocument)client.Documents[url]; if (document != null) { return(document); } string contentType = null; Stream stream = client.Download(ref url, ref contentType); try { XmlTextReader xmlReader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))) { WhitespaceHandling = WhitespaceHandling.Significant, XmlResolver = null, DtdProcessing = DtdProcessing.Prohibit }; if (!DiscoveryDocument.CanRead(xmlReader)) { ArgumentException innerException = new ArgumentException(System.Web.Services.Res.GetString("WebInvalidFormat")); throw new InvalidOperationException(System.Web.Services.Res.GetString("WebMissingDocument", new object[] { url }), innerException); } document2 = DiscoveryDocument.Read(xmlReader); } finally { stream.Close(); } return(document2); }
internal void ResolveInternal(DiscoveryClientProtocol prot, XmlSchema xsd) { if (xsd.Includes.Count == 0) { return; } foreach (XmlSchemaExternal ext in xsd.Includes) { if (ext.SchemaLocation == null) { continue; } // Make relative uris to absoulte Uri uri = new Uri(BaseUri, ext.SchemaLocation); string url = uri.ToString(); if (prot.Documents.Contains(url)) // Already resolved { continue; } try { string contentType = null; Stream stream = prot.Download(ref url, ref contentType); XmlTextReader reader = new XmlTextReader(url, stream); reader.XmlResolver = null; reader.MoveToContent(); DiscoveryReference refe; XmlSchema schema = XmlSchema.Read(reader, null); refe = new SchemaReference(); refe.ClientProtocol = prot; refe.Url = url; prot.Documents.Add(url, schema); ((SchemaReference)refe).ResolveInternal(prot, schema); if (!prot.References.Contains(url)) { prot.References.Add(refe); } stream.Close(); } catch (Exception ex) { ReportError(url, ex); } } }
public void Resolve() { if (clientProtocol == null) { throw new InvalidOperationException("The ClientProtocol property is a null reference."); } if (clientProtocol.Documents.Contains(Url)) // Already resolved { return; } try { string contentType = null; string url = Url; Stream stream = clientProtocol.Download(ref url, ref contentType); Resolve(contentType, stream); } catch (Exception ex) { ReportError(Url, ex); } }
internal void ResolveInternal (DiscoveryClientProtocol prot, ServiceDescription wsdl) { if (wsdl.Imports == null) return; foreach (Import import in wsdl.Imports) { // Make relative uris to absoulte Uri uri = new Uri (BaseUri, import.Location); string url = uri.ToString (); if (prot.Documents.Contains (url)) // Already resolved continue; try { string contentType = null; Stream stream = prot.Download (ref url, ref contentType); XmlTextReader reader = new XmlTextReader (url, stream); reader.XmlResolver = null; reader.MoveToContent (); DiscoveryReference refe; if (ServiceDescription.CanRead (reader)) { ServiceDescription refWsdl = ServiceDescription.Read (reader); refe = new ContractReference (); refe.ClientProtocol = prot; refe.Url = url; ((ContractReference)refe).ResolveInternal (prot, refWsdl); prot.Documents.Add (url, refWsdl); } else { XmlSchema schema = XmlSchema.Read (reader, null); refe = new SchemaReference (); refe.ClientProtocol = prot; refe.Url = url; prot.Documents.Add (url, schema); } if (!prot.References.Contains (url)) prot.References.Add (refe); reader.Close (); } catch (Exception ex) { ReportError (url, ex); } } foreach (XmlSchema schema in wsdl.Types.Schemas) { // the schema itself is not added to the // references, but it has to resolve includes. Uri uri = BaseUri; string url = uri.ToString (); SchemaReference refe = new SchemaReference (); refe.ClientProtocol = prot; refe.Url = url; refe.ResolveInternal (prot, schema); } }
/// <include file='doc\DiscoveryDocumentReference.uex' path='docs/doc[@for="DiscoveryDocumentReference.GetDocumentNoParse"]/*' /> /// <devdoc> /// Retrieves a discovery document from Url, either out of the ClientProtocol /// or from a stream. Does not /// </devdoc> private static DiscoveryDocument GetDocumentNoParse(ref string url, DiscoveryClientProtocol client) { DiscoveryDocument d = (DiscoveryDocument) client.Documents[url]; if (d != null) { return d; } string contentType = null; Stream stream = client.Download(ref url, ref contentType); try { XmlTextReader reader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))); reader.WhitespaceHandling = WhitespaceHandling.Significant; reader.XmlResolver = null; reader.DtdProcessing = DtdProcessing.Prohibit; if (!DiscoveryDocument.CanRead(reader)) { // there is no discovery document at this location ArgumentException exception = new ArgumentException(Res.GetString(Res.WebInvalidFormat)); throw new InvalidOperationException(Res.GetString(Res.WebMissingDocument, url), exception); } return DiscoveryDocument.Read(reader); } finally { stream.Close(); } }
internal void ResolveInternal(DiscoveryClientProtocol prot, ServiceDescription wsdl) { if (wsdl.Imports == null) { return; } foreach (Import import in wsdl.Imports) { // Make relative uris to absoulte Uri uri = new Uri(BaseUri, import.Location); string url = uri.ToString(); if (prot.Documents.Contains(url)) // Already resolved { continue; } try { string contentType = null; Stream stream = prot.Download(ref url, ref contentType); XmlTextReader reader = new XmlTextReader(url, stream); reader.XmlResolver = null; reader.MoveToContent(); DiscoveryReference refe; if (ServiceDescription.CanRead(reader)) { ServiceDescription refWsdl = ServiceDescription.Read(reader); refe = new ContractReference(); refe.ClientProtocol = prot; refe.Url = url; ((ContractReference)refe).ResolveInternal(prot, refWsdl); prot.Documents.Add(url, refWsdl); } else { XmlSchema schema = XmlSchema.Read(reader, null); refe = new SchemaReference(); refe.ClientProtocol = prot; refe.Url = url; prot.Documents.Add(url, schema); } if (!prot.References.Contains(url)) { prot.References.Add(refe); } reader.Close(); } catch (Exception ex) { ReportError(url, ex); } } foreach (XmlSchema schema in wsdl.Types.Schemas) { // the schema itself is not added to the // references, but it has to resolve includes. Uri uri = BaseUri; string url = uri.ToString(); SchemaReference refe = new SchemaReference(); refe.ClientProtocol = prot; refe.Url = url; refe.ResolveInternal(prot, schema); } }
internal void ResolveInternal (DiscoveryClientProtocol prot, XmlSchema xsd) { if (xsd.Includes.Count == 0) return; foreach (XmlSchemaExternal ext in xsd.Includes) { if (ext.SchemaLocation == null) continue; // Make relative uris to absoulte Uri uri = new Uri (BaseUri, ext.SchemaLocation); string url = uri.ToString (); if (prot.Documents.Contains (url)) // Already resolved continue; try { string contentType = null; Stream stream = prot.Download (ref url, ref contentType); XmlTextReader reader = new XmlTextReader (url, stream); reader.XmlResolver = null; reader.MoveToContent (); DiscoveryReference refe; XmlSchema schema = XmlSchema.Read (reader, null); refe = new SchemaReference (); refe.ClientProtocol = prot; refe.Url = url; prot.Documents.Add (url, schema); ((SchemaReference)refe).ResolveInternal (prot, schema); if (!prot.References.Contains (url)) prot.References.Add (refe); stream.Close (); } catch (Exception ex) { ReportError (url, ex); } } }