This documentation is archived and is not being maintained.

SchemaReference Class

Represents a reference in a discovery document to an XML Schema Definition (XSD) language schema. This class cannot be inherited.


Namespace:  System.Web.Services.Discovery
Assembly:  System.Web.Services (in System.Web.Services.dll)

public sealed class SchemaReference : DiscoveryReference

The SchemaReference type exposes the following members.

Public methodSchemaReference()Initializes a new instance of the SchemaReference class using default values.
Public methodSchemaReference(String)Initializes a new instance of the SchemaReference class using the supplied URL as the XSD schema reference.

Public propertyClientProtocolGets or sets the instance of DiscoveryClientProtocol used in a discovery process. (Inherited from DiscoveryReference.)
Public propertyDefaultFilenameGets the name of the default file to use when saving the referenced XSD schema. (Overrides DiscoveryReference.DefaultFilename.)
Public propertyRefGets or sets the URL to the referenced XSD schema.
Public propertySchemaGets an XmlSchema object representing the XSD schema.
Public propertyTargetNamespaceGets or sets the targetNamespace XML attribute of the XSD schema.
Public propertyUrlGets or sets the URL for the schema reference. (Overrides DiscoveryReference.Url.)

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReadDocumentReads and returns the XSD schema from the passed Stream. (Overrides DiscoveryReference.ReadDocument(Stream).)
Public methodResolve()Downloads the referenced document at Url to resolve whether the referenced document is valid. (Inherited from DiscoveryReference.)
Protected methodResolve(String, Stream)Resolves whether the referenced document is valid. (Inherited from DiscoveryReference.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWriteDocumentWrites the passed XSD schema into the passed Stream. (Overrides DiscoveryReference.WriteDocument(Object, Stream).)

Public fieldStatic memberNamespaceXML namespace for XSD schema references in discovery documents.

XML Web services discovery involves discovering the available XML Web services given, a URL. A The URL typically points to a discovery document, which usually has a.disco file name extension. The discovery document contains references to information about the existance of XML Web services. These references can refer to service descriptions, XSD schemas, or other discovery documents. This class represents a reference to an XSD schema.

Within a discovery document, a reference to an XSD schema is contained within a schemaRef XML element. The schemaRef XML element has an XML namespace and a ref attribute. The value of the XML namespace must match the Namespace constant. The value of the ref attribute is placed in the Ref property.

using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Xml.Schema;
using System.Web.Services.Discovery;

public class SchemaReferenceClass
   public static void Main()

         // Reference the schema document.
         string myStringUrl = "c:\\Inetpub\\wwwroot\\dataservice.xsd";
         XmlSchema myXmlSchema;

         // Create the client protocol.
         DiscoveryClientProtocol myDiscoveryClientProtocol = 
             new DiscoveryClientProtocol();
         myDiscoveryClientProtocol.Credentials = 

         //  Create a schema reference.
         SchemaReference mySchemaReferenceNoParam = new SchemaReference();

         SchemaReference mySchemaReference = new SchemaReference(myStringUrl);

         // Set the client protocol.
         mySchemaReference.ClientProtocol = myDiscoveryClientProtocol;

         // Access the default file name associated with the schema reference.
         Console.WriteLine("Default filename is : " + 

         // Access the namespace associated with schema reference class.
         Console.WriteLine("Namespace is : " + SchemaReference.Namespace);

         FileStream myStream = 
             new FileStream(myStringUrl,FileMode.OpenOrCreate); 

         // Read the document in a stream.

         // Get the schema of referenced document.
         myXmlSchema = mySchemaReference.Schema;

         Console.WriteLine("Reference is : " + mySchemaReference.Ref);      

         Console.WriteLine("Target namespace (default empty) is : " + 

         Console.WriteLine("URL is : " + mySchemaReference.Url);

         // Write the document in the stream.

         mySchemaReference = null;

      catch (Exception e)

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.