Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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
public final class SchemaReference extends DiscoveryReference
public final class SchemaReference extends DiscoveryReference
Not applicable.

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());
      }
   }
}


import System.*;
import System.IO.*;
import System.Net.*;
import System.Xml.*;
import System.Xml.Schema.*;
import System.Web.Services.Discovery.*;

public class SchemaReferenceClass
{
    public static void main(String[] args)
    {      
        try {
            // Reference the schema document.
            String myStringUrl = "c:\\Inetpub\\wwwroot\\dataservice.xsd";
            XmlSchema myXmlSchema;
            // Create the client protocol.
            DiscoveryClientProtocol myDiscoveryClientProtocol = 
                new DiscoveryClientProtocol();
            myDiscoveryClientProtocol.set_Credentials(CredentialCache.
                get_DefaultCredentials());
            //  Create a schema reference.
            SchemaReference mySchemaReferenceNoParam = new SchemaReference();
            SchemaReference mySchemaReference = new SchemaReference(myStringUrl);
            // Set the client protocol.
            mySchemaReference.set_ClientProtocol(myDiscoveryClientProtocol);
            // Access the default file name associated with the schema reference.
            Console.WriteLine("Default filename is : " + mySchemaReference.
                get_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.get_Schema();
            Console.WriteLine("Reference is : " + mySchemaReference.get_Ref());
            Console.WriteLine("Target namespace (default empty) is : " 
                + mySchemaReference.get_TargetNamespace());
            Console.WriteLine("URL is : " + mySchemaReference.get_Url());
            // Write the document in the stream.
            mySchemaReference.WriteDocument(myXmlSchema, myStream);
            myStream.Close();
            mySchemaReference = null;
        }
        catch (System.Exception e) {
            Console.WriteLine(e.ToString());
        }
    } //main
} //SchemaReferenceClass

System.Object
   System.Web.Services.Discovery.DiscoveryReference
    System.Web.Services.Discovery.SchemaReference
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.