SchemaReference Klasa

Definicja

Reprezentuje odwołanie w dokumencie odnajdywania do schematu języka definicji schematu XML (XSD). Klasa ta nie może być dziedziczona.

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
Dziedziczenie
SchemaReference

Przykłady

#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

Uwagi

Odnajdywanie usług sieci Web XML obejmuje odnajdywanie dostępnych usług sieci Web XML podanych jako adres URL. Adres URL zazwyczaj wskazuje dokument odnajdywania, który zwykle ma rozszerzenie nazwy pliku disco. Dokument odnajdywania zawiera odwołania do informacji o istnieniu usług sieci Web XML. Te odwołania mogą odnosić się do opisów usług, schematów XSD lub innych dokumentów odnajdywania. Ta klasa reprezentuje odwołanie do schematu XSD.

W dokumencie odnajdywania odwołanie do schematu XSD znajduje się w elemencie schemaRef XML. Element schemaRef XML ma przestrzeń nazw XML i ref atrybut. Wartość przestrzeni nazw XML musi być zgodna ze stałą Namespace . Wartość atrybutu ref jest umieszczana we Ref właściwości .

Konstruktory

SchemaReference()

Inicjuje SchemaReference nowe wystąpienie klasy przy użyciu wartości domyślnych.

SchemaReference(String)

Inicjuje nowe wystąpienie SchemaReference klasy przy użyciu podanego adresu URL jako odwołania do schematu XSD.

Pola

Namespace

Przestrzeń nazw XML dla odwołań schematu XSD w dokumentach odnajdywania.

Właściwości

ClientProtocol

Pobiera lub ustawia wystąpienie DiscoveryClientProtocol używane w procesie odnajdywania.

(Odziedziczone po DiscoveryReference)
DefaultFilename

Pobiera nazwę pliku domyślnego, który ma być używany podczas zapisywania przywoływnego schematu XSD.

Ref

Pobiera lub ustawia adres URL na przywołyny schemat XSD.

Schema

XmlSchema Pobiera obiekt reprezentujący schemat XSD.

TargetNamespace

Pobiera lub ustawia targetNamespace atrybut XML schematu XSD.

Url

Pobiera lub ustawia adres URL odwołania do schematu.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ReadDocument(Stream)

Odczytuje i zwraca schemat XSD z przekazanego Streamelementu .

Resolve()

Pobiera przywołyny dokument pod adresem Url , aby rozwiązać problem z prawidłowym dokumentem, do których się odwołujesz.

(Odziedziczone po DiscoveryReference)
Resolve(String, Stream)

Rozwiązuje, czy dokument, do których się odwołujesz, jest prawidłowy.

(Odziedziczone po DiscoveryReference)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
WriteDocument(Object, Stream)

Zapisuje przekazany schemat XSD do przekazanego Streamelementu .

Dotyczy

Zobacz też