Export (0) Print
Expand All

DiscoveryClientProtocol.DiscoveryClientResultsFile Class

Represents the root element of an XML document containing the results of all files written when the WriteAll method is invoked.

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

System.Object
   System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoveryClientResultsFile

[Visual Basic]
NotInheritable Public Class _
   DiscoveryClientProtocol.DiscoveryClientResultsFile
[C#]
public sealed class
   DiscoveryClientProtocol.DiscoveryClientResultsFile
[C++]
public __gc __sealed class
   DiscoveryClientProtocol.DiscoveryClientResultsFile
[JScript]
public class DiscoveryClientProtocol.DiscoveryClientResultsFile

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

When you invoke the DiscoveryClientProtocol.WriteAll method, all resolved discovery documents and a file containing a map of all those files are saved to a directory. The map file is described in XML with the root element being DiscoveryClientProtocol.DiscoveryClientResultsFile; this class is passed to the XmlSerializer class to serialize the results.

Example

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

Class myDiscoveryClient_Results
   
   Shared Sub Main()
      Dim outputDirectory As String = "c:\InetPub\wwwroot"
      Dim myClient As New DiscoveryClientProtocol()
      
      ' Use default credentials to access the URL being discovered.
      myClient.Credentials = CredentialCache.DefaultCredentials
      Try
          Dim myDocument As DiscoveryDocument
          ' Discover the supplied URL to determine if it is a discovery document.
          myDocument = myClient.Discover("http://localhost/MathService_vb.vsdisco")
          myClient.ResolveAll()
          Dim myCollection As DiscoveryClientResultCollection = _ 
              myClient.WriteAll(outputDirectory, "MyDiscoMap.discomap")
         ' Get the DiscoveryClientProtocol.DiscoveryClientResultsFile.
         Dim myResultFile As New DiscoveryClientProtocol.DiscoveryClientResultsFile()
         Dim mySerializer As New XmlSerializer(myResultFile.GetType())
         Dim reader = New XmlTextReader("http://localhost/MyDiscoMap.discomap")
         myResultFile = CType(mySerializer.Deserialize(reader), _ 
             DiscoveryClientProtocol.DiscoveryClientResultsFile)

         ' Get a collection of 'DiscoveryClientResult' objects.
         Dim myResultcollection As DiscoveryClientResultCollection = _
             myResultFile.Results

         Console.WriteLine("Referred file(s) : ")
         Dim myResult As DiscoveryClientResult
         For Each myResult In  myResultcollection
            Console.WriteLine(myResult.Filename)
         Next myResult
      Catch e As Exception
         Console.WriteLine(e.Message)
      End Try
   End Sub 'Main
End Class 'myDiscoveryClient_Results

[C#] 
using System;
using System.Web.Services.Discovery;
using System.Net;
using System.Xml;
using System.Xml.Serialization;

class myDiscoveryClient_Results
{
   static void Main()
   {
      string outputDirectory = "c:\\InetPub\\wwwroot";
      DiscoveryClientProtocol myClient = new DiscoveryClientProtocol();
      
      //  Use default credentials to access the URL being discovered.
      myClient.Credentials = CredentialCache.DefaultCredentials;
      try 
      {
         DiscoveryDocument myDocument;

         // Discover the supplied URL to determine if it is a discovery document.
         myDocument = myClient.Discover("http://localhost/MathService_cs.vsdisco");
         myClient.ResolveAll();
         DiscoveryClientResultCollection myCollection = 
             myClient.WriteAll(outputDirectory, "MyDiscoMap.discomap");
         // Get the DiscoveryClientProtocol.DiscoveryClientResultsFile.
         DiscoveryClientProtocol.DiscoveryClientResultsFile myResultFile =
             new DiscoveryClientProtocol.DiscoveryClientResultsFile();
         XmlSerializer mySerializer = new XmlSerializer(myResultFile.GetType()); 
         XmlReader reader = new XmlTextReader("http://localhost/MyDiscoMap.discomap");
         myResultFile = (DiscoveryClientProtocol.DiscoveryClientResultsFile)
             mySerializer.Deserialize(reader);

         // Get a collection of DiscoveryClientResult objects.
         DiscoveryClientResultCollection myResultcollection = myResultFile.Results;

         Console.WriteLine("Referred file(s): ");
         foreach(DiscoveryClientResult myResult in myResultcollection)
         {
             Console.WriteLine(myResult.Filename);
         }
      }
      catch(Exception e)
      {
          Console.WriteLine(e.Message);
      }
   }
}

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

int main()
{
   String* outputDirectory = S"c:\\InetPub\\wwwroot";
   DiscoveryClientProtocol* myClient = new DiscoveryClientProtocol();

   //  Use default credentials to access the URL being discovered.
   myClient->Credentials = CredentialCache::DefaultCredentials;
   try 
   {
      DiscoveryDocument* myDocument;

      // Discover the supplied URL to determine if it is a discovery document.
      myDocument = myClient->Discover(S"http://localhost/MathService_cs.vsdisco");
      myClient->ResolveAll();
      DiscoveryClientResultCollection* myCollection = 
         myClient->WriteAll(outputDirectory, S"MyDiscoMap.discomap");
      // Get the DiscoveryClientProtocol.DiscoveryClientResultsFile.
      DiscoveryClientProtocol::DiscoveryClientResultsFile* myResultFile =
         new DiscoveryClientProtocol::DiscoveryClientResultsFile();
      XmlSerializer* mySerializer = new XmlSerializer(myResultFile->GetType()); 
      XmlReader* reader = new XmlTextReader(S"http://localhost/MyDiscoMap.discomap");
      myResultFile = dynamic_cast<DiscoveryClientProtocol::DiscoveryClientResultsFile*>
         (mySerializer->Deserialize(reader));

      // Get a collection of DiscoveryClientResult objects.
      DiscoveryClientResultCollection* myResultcollection = myResultFile->Results;

      Console::WriteLine(S"Referred file(s): ");
      System::Collections::IEnumerator* myEnum = myResultcollection->GetEnumerator();
      while (myEnum->MoveNext())
      {
         DiscoveryClientResult* myResult = __try_cast<DiscoveryClientResult*>(myEnum->Current);
         Console::WriteLine(myResult->Filename);
      }
   }
   catch(Exception* e)
   {
      Console::WriteLine(e->Message);
   }
}

[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

DiscoveryClientProtocol.DiscoveryClientResultsFile Members | System.Web.Services.Discovery Namespace

Show:
© 2014 Microsoft