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 Web 服务发现涉及发现给定的可用 XML Web 服务(URL)。 URL 通常指向发现文档,该文档通常具有 a.disco 文件扩展名。 发现文档包含对 XML Web 服务存在的信息的引用。 这些引用可以引用服务说明、XSD 架构或其他发现文档。 此类表示对 XSD 架构的引用。

在发现文档中,对 XSD 架构的引用包含在 XML 元素中 schemaRefschemaRef XML 元素具有 XML 命名空间和ref属性。 XML 命名空间的值必须与 常量匹配 Namespace 。 属性的值 ref 放置在 属性中 Ref

构造函数

SchemaReference()

使用默认值初始化 SchemaReference 类的新实例。

SchemaReference(String)

使用作为 XSD 架构引用提供的 URL 初始化 SchemaReference 类的新实例。

字段

Namespace

发现文档中 XSD 架构引用的 XML 命名空间。

属性

ClientProtocol

获取或设置在发现过程中使用的 DiscoveryClientProtocol 的实例。

(继承自 DiscoveryReference)
DefaultFilename

获取保存引用的 XSD 架构时要使用的默认文件的名称。

Ref

获取或设置引用的 XSD 架构的 URL。

Schema

获取一个表示 XSD 架构的 XmlSchema 对象。

TargetNamespace

获取或设置 XSD 架构的 targetNamespace XML 特性。

Url

获取或设置架构引用的 URL。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ReadDocument(Stream)

从传递的 Stream 读取并返回 XSD 架构。

Resolve()

下载 Url 处的引用文档以解析引用的文档是否有效。

(继承自 DiscoveryReference)
Resolve(String, Stream)

解析引用的文档是否有效。

(继承自 DiscoveryReference)
ToString()

返回表示当前对象的字符串。

(继承自 Object)
WriteDocument(Object, Stream)

将传递的 XSD 架构写入传递的 Stream

适用于

另请参阅