DiscoveryDocument Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Представляет документ обнаружения. Этот класс не может быть унаследован.
public ref class DiscoveryDocument sealed
public sealed class DiscoveryDocument
type DiscoveryDocument = class
Public NotInheritable Class DiscoveryDocument
- Наследование
-
DiscoveryDocument
Примеры
Следующий пример кода считывает документ обнаружения из файла с помощью Read файла и записывает его обратно в файл с помощью Write метода.
#using <System.Xml.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Xml;
using namespace System::IO;
using namespace System::Web::Services::Discovery;
using namespace System::Collections;
int main()
{
try
{
// Create an Object* of the 'DiscoveryDocument'.
DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument;
// Create an XmlTextReader with the sample file.
XmlTextReader^ myXmlTextReader = gcnew XmlTextReader( "http://localhost/example_cs.disco" );
// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader );
// Write the DiscoveryDocument into the 'TextWriter'.
FileStream^ myFileStream = gcnew FileStream( "log.txt",FileMode::OpenOrCreate,FileAccess::Write );
StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
myDiscoveryDocument->Write( myStreamWriter );
myStreamWriter->Flush();
myStreamWriter->Close();
// Display the contents of the DiscoveryDocument onto the console.
FileStream^ myFileStream1 = gcnew FileStream( "log.txt",FileMode::OpenOrCreate,FileAccess::Read );
StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 );
// Set the file pointer to the begin.
myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin );
Console::WriteLine( "The contents of the DiscoveryDocument are-" );
while ( myStreamReader->Peek() > -1 )
{
Console::WriteLine( myStreamReader->ReadLine() );
}
myStreamReader->Close();
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception raised : {0}", e->Message );
}
}
using System;
using System.Xml;
using System.IO;
using System.Web.Services.Discovery;
using System.Collections;
public class DiscoveryDocument_Example
{
static void Main()
{
try
{
// Create an object of the 'DiscoveryDocument'.
DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();
// Create an XmlTextReader with the sample file.
XmlTextReader myXmlTextReader = new
XmlTextReader( "http://localhost/example_cs.disco" );
// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument.Read( myXmlTextReader );
// Write the DiscoveryDocument into the 'TextWriter'.
FileStream myFileStream = new
FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Write );
StreamWriter myStreamWriter = new StreamWriter( myFileStream );
myDiscoveryDocument.Write( myStreamWriter );
myStreamWriter.Flush();
myStreamWriter.Close();
// Display the contents of the DiscoveryDocument onto the console.
FileStream myFileStream1 = new
FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Read );
StreamReader myStreamReader = new StreamReader( myFileStream1 );
// Set the file pointer to the begin.
myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);
Console.WriteLine( "The contents of the DiscoveryDocument are-" );
while ( myStreamReader.Peek() > -1 )
{
Console.WriteLine( myStreamReader.ReadLine() );
}
myStreamReader.Close();
}
catch( Exception e )
{
Console.WriteLine( "Exception raised : {0}", e.Message);
}
}
}
Imports System.Xml
Imports System.IO
Imports System.Web.Services.Discovery
Imports System.Collections
Public Class DiscoveryDocument_Example
Shared Sub Main()
Try
' Create an object of the 'DiscoveryDocument'.
Dim myDiscoveryDocument As New DiscoveryDocument()
' Create an XmlTextReader with the sample file.
Dim myXmlTextReader As New XmlTextReader("http://localhost/example_vb.disco")
' Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader)
' Write the DiscoveryDocument into the 'TextWriter'.
Dim myFileStream As New FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim myStreamWriter As New StreamWriter(myFileStream)
myDiscoveryDocument.Write(myStreamWriter)
myStreamWriter.Flush()
myStreamWriter.Close()
' Display the contents of the DiscoveryDocument onto the console.
Dim myFileStream1 As New FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Read)
Dim myStreamReader As New StreamReader(myFileStream1)
' Set the file pointer to the begin.
myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin)
Console.WriteLine("The contents of the DiscoveryDocument are-")
While myStreamReader.Peek() > - 1
Console.WriteLine(myStreamReader.ReadLine())
End While
myStreamReader.Close()
Catch e As Exception
Console.WriteLine("Exception raised : {0}", e.Message.ToString())
End Try
End Sub
End Class
Комментарии
Обнаружение веб-служб XML включает обнаружение доступных веб-служб XML с указанием URL-адреса. URL-адрес обычно указывает на документ обнаружения, который обычно имеет расширение имени файла диско. Документ обнаружения, который является XML-документом, содержит ссылки на сведения о существовании веб-служб XML, таких как описание службы, схема языка определения схемы XML (XSD) или другой документ обнаружения. Этот класс представляет содержимое документа обнаружения; References где свойство содержит список ссылок, содержащихся в документе обнаружения.
Конструкторы
| Имя | Описание |
|---|---|
| DiscoveryDocument() |
Инициализирует новый экземпляр класса DiscoveryDocument. |
Поля
| Имя | Описание |
|---|---|
| Namespace |
Пространство имен XML-элемента обнаружения документа обнаружения. |
Свойства
| Имя | Описание |
|---|---|
| References |
Список ссылок, содержащихся в документе обнаружения. |
Методы
| Имя | Описание |
|---|---|
| CanRead(XmlReader) |
Возвращает значение, указывающее, можно ли десериализировать переданный XmlReader в объект DiscoveryDocument. |
| Equals(Object) |
Определяет, равен ли указанный объект текущему объекту. (Унаследовано от Object) |
| GetHashCode() |
Служит хэш-функцией по умолчанию. (Унаследовано от Object) |
| GetType() |
Возвращает Type текущего экземпляра. (Унаследовано от Object) |
| MemberwiseClone() |
Создает неглубокую копию текущей Object. (Унаследовано от Object) |
| Read(Stream) |
Считывает и возвращает DiscoveryDocument значение из переданного Stream. |
| Read(TextReader) |
Считывает и возвращает DiscoveryDocument значение из переданного TextReader. |
| Read(XmlReader) |
Считывает и возвращает DiscoveryDocument значение из переданного XmlReader. |
| ToString() |
Возвращает строку, представляющую текущий объект. (Унаследовано от Object) |
| Write(Stream) |
Записывает это DiscoveryDocument в переданный Stream. |
| Write(TextWriter) |
Записывает это DiscoveryDocument в переданный TextWriter. |
| Write(XmlWriter) |
Записывает это DiscoveryDocument в переданный XmlWriter. |