SchemaReference Class

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)

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

public sealed class SchemaReference : DiscoveryReference

NameDescription
System_CAPS_pubmethodSchemaReference()

Initializes a new instance of the SchemaReference class using default values.

System_CAPS_pubmethodSchemaReference(String)

Initializes a new instance of the SchemaReference class using the supplied URL as the XSD schema reference.

NameDescription
System_CAPS_pubpropertyClientProtocol

Gets or sets the instance of DiscoveryClientProtocol used in a discovery process.(Inherited from DiscoveryReference.)

System_CAPS_pubpropertyDefaultFilename

Gets the name of the default file to use when saving the referenced XSD schema.(Overrides DiscoveryReference.DefaultFilename.)

System_CAPS_pubpropertyRef

Gets or sets the URL to the referenced XSD schema.

System_CAPS_pubpropertySchema

Gets an XmlSchema object representing the XSD schema.

System_CAPS_pubpropertyTargetNamespace

Gets or sets the targetNamespace XML attribute of the XSD schema.

System_CAPS_pubpropertyUrl

Gets or sets the URL for the schema reference.(Overrides DiscoveryReference.Url.)

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodReadDocument(Stream)

Reads and returns the XSD schema from the passed Stream.(Overrides DiscoveryReference.ReadDocument(Stream).)

System_CAPS_pubmethodResolve()

Downloads the referenced document at Url to resolve whether the referenced document is valid.(Inherited from DiscoveryReference.)

System_CAPS_protmethodResolve(String, Stream)

Resolves whether the referenced document is valid.(Inherited from DiscoveryReference.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodWriteDocument(Object, Stream)

Writes the passed XSD schema into the passed Stream.(Overrides DiscoveryReference.WriteDocument(Object, Stream).)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticNamespace

XML 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()
   {
      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
Available since 1.1

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

Return to top
Show:
© 2016 Microsoft