Export (0) Print
Expand All

SchemaReference Class

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

System.Object
  System.Web.Services.Discovery.DiscoveryReference
    System.Web.Services.Discovery.SchemaReference

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.

  NameDescription
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.
Top

  NameDescription
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.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (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).)
Top

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

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()
   {
      try
      {


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

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

         //  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 : " + 
             mySchemaReference.DefaultFilename);

         // 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.
         mySchemaReference.ReadDocument(myStream);

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

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

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

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

         // Write the document in the stream.
         mySchemaReference.WriteDocument(myXmlSchema,myStream);

         myStream.Close();
         mySchemaReference = null;

      }
      catch (Exception e)
      {
         Console.WriteLine(e.ToString());
      }
   }
}

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft