Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SchemaReference Class

SchemaReference Class

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

For a list of all members of this type, see SchemaReference Members.

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

[Visual Basic]
NotInheritable Public Class SchemaReference
   Inherits DiscoveryReference
[C#]
public sealed class SchemaReference : DiscoveryReference
[C++]
public __gc __sealed class SchemaReference : public
   DiscoveryReference
[JScript]
public class SchemaReference extends DiscoveryReference

Thread Safety

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

Remarks

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.

Example

[Visual Basic] 
Imports System
Imports System.IO
Imports System.Net
Imports System.Xml
Imports System.Xml.Schema
Imports System.Web.Services.Discovery

Public Module SchemaReferenceModule

   Public Sub Main()
      Try


         ' Reference the schema document.
         Dim myStringUrl As String = "c:\\Inetpub\\wwwroot\\dataservice.xsd"
         Dim myXmlSchema As XmlSchema

         ' Create the client protocol.
         Dim myDiscoveryClientProtocol As DiscoveryClientProtocol = _
             New DiscoveryClientProtocol()
         myDiscoveryClientProtocol.Credentials = _
             CredentialCache.DefaultCredentials

         ' Create a schema reference.
         Dim mySchemaReferenceNoParam As SchemaReference = New SchemaReference()

         Dim mySchemaReference As SchemaReference = _
             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)

         Dim myStream As FileStream = _
             New FileStream(myStringUrl, FileMode.OpenOrCreate)

         ' Read the document in a stream.
         mySchemaReference.ReadDocument(myStream)

         ' Get the schema of the 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 = Nothing
      Catch e As Exception

         Console.WriteLine(e.ToString)

      End Try

   End Sub
End Module


[C#] 
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());
      }
   }
}


[C++] 
#using <mscorlib.dll>
#using <System.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::IO;
using namespace System::Net;
using namespace System::Xml;
using namespace System::Xml::Schema;
using namespace System::Web::Services::Discovery;

int main() {
   try {

      // Reference the schema document.
      String* myStringUrl = S"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(S"Default filename is : {0}",
         mySchemaReference->DefaultFilename);

      // Access the namespace associated with schema reference class.
      Console::WriteLine(S"Namespace is : {0}", 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(S"Reference is : {0}", mySchemaReference->Ref);

      Console::WriteLine(S"Target namespace (default empty) is : {0}",
         mySchemaReference->TargetNamespace);

      Console::WriteLine(S"URL is : {0}", mySchemaReference->Url);

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

      myStream->Close();
      mySchemaReference = 0;

   } catch (Exception* e) {
      Console::WriteLine(e);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.Services.Discovery

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

SchemaReference Members | System.Web.Services.Discovery Namespace | XmlSchema | DiscoveryReference | DiscoveryDocumentReference | ContractReference | DiscoveryClientProtocol

Show:
© 2015 Microsoft