Бөлісу құралы:


SchemaReference Класс

Определение

Представляет ссылку в документе обнаружения на схему языка определения СХЕМЫ XML (XSD). Этот класс не может быть унаследован.

public ref class SchemaReference sealed : System::Web::Services::Discovery::DiscoveryReference
public sealed class SchemaReference : System.Web.Services.Discovery.DiscoveryReference
type SchemaReference = class
    inherit DiscoveryReference
Public NotInheritable Class SchemaReference
Inherits DiscoveryReference
Наследование
SchemaReference

Примеры

#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 = "c:\\Inetpub\\wwwroot\\dataservice.xsd";
      XmlSchema^ myXmlSchema;
      
      // Create the client protocol.
      DiscoveryClientProtocol^ myDiscoveryClientProtocol = gcnew DiscoveryClientProtocol;
      myDiscoveryClientProtocol->Credentials = CredentialCache::DefaultCredentials;
      
      //  Create a schema reference.
      SchemaReference^ mySchemaReferenceNoParam = gcnew SchemaReference;
      SchemaReference^ mySchemaReference = gcnew SchemaReference( myStringUrl );
      
      // Set the client protocol.
      mySchemaReference->ClientProtocol = myDiscoveryClientProtocol;
      
      // Access the default file name associated with the schema reference.
      Console::WriteLine( "Default filename is : {0}", mySchemaReference->DefaultFilename );
      
      // Access the namespace associated with schema reference class.
      Console::WriteLine( "Namespace is : {0}", SchemaReference::Namespace );
      FileStream^ myStream = gcnew 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 : {0}", mySchemaReference->Ref );
      Console::WriteLine( "Target namespace (default empty) is : {0}", mySchemaReference->TargetNamespace );
      Console::WriteLine( "URL is : {0}", mySchemaReference->Url );
      
      // Write the document in the stream.
      mySchemaReference->WriteDocument( myXmlSchema, myStream );
      myStream->Close();
      mySchemaReference = nullptr;
      
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e );
   }

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

Комментарии

Обнаружение веб-служб XML включает обнаружение доступных веб-служб XML, заданных URL-адресом. URL-адрес обычно указывает на документ обнаружения, который обычно имеет расширение имени файла диско. Документ обнаружения содержит ссылки на сведения о существовании веб-служб XML. Эти ссылки могут ссылаться на описания служб, схемы XSD или другие документы обнаружения. Этот класс представляет ссылку на схему XSD.

В документе обнаружения ссылка на схему XSD содержится в XML-элементе schemaRef . Xml-элемент schemaRef имеет пространство имен XML и ref атрибут. Значение пространства имен XML должно соответствовать константе Namespace . Значение атрибута ref помещается в Ref свойство.

Конструкторы

Имя Описание
SchemaReference()

Инициализирует новый экземпляр класса с помощью значений SchemaReference по умолчанию.

SchemaReference(String)

Инициализирует новый экземпляр SchemaReference класса, используя предоставленный URL-адрес в качестве ссылки на схему XSD.

Поля

Имя Описание
Namespace

Пространство имен XML для ссылок на схемы XSD в документах обнаружения.

Свойства

Имя Описание
ClientProtocol

Возвращает или задает экземпляр, используемый DiscoveryClientProtocol в процессе обнаружения.

(Унаследовано от DiscoveryReference)
DefaultFilename

Возвращает имя файла по умолчанию, используемого при сохранении указанной схемы XSD.

Ref

Возвращает или задает URL-адрес указанной схемы XSD.

Schema

XmlSchema Возвращает объект, представляющий схему XSD.

TargetNamespace

Возвращает или задает targetNamespace XML-атрибут схемы XSD.

Url

Возвращает или задает URL-адрес для ссылки на схему.

Методы

Имя Описание
Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает Type текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неглубокую копию текущей Object.

(Унаследовано от Object)
ReadDocument(Stream)

Считывает и возвращает схему XSD из переданного Stream.

Resolve()

Загружает указанный в ссылке документ Url , чтобы устранить, является ли указанный документ допустимым.

(Унаследовано от DiscoveryReference)
Resolve(String, Stream)

Разрешает, является ли указанный документ допустимым.

(Унаследовано от DiscoveryReference)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)
WriteDocument(Object, Stream)

Записывает переданную схему XSD в переданную Stream.

Применяется к

См. также раздел