DiscoveryClientProtocol.WriteAll(String, String) Método

Definição

Grava todos os documentos de descoberta, esquemas de XSD (definição de esquema XML) e descrições de serviços na propriedade Documents para o diretório fornecido e cria um arquivo nesse diretório.Writes all discovery documents, XML Schema Definition (XSD) schemas, and Service Descriptions in the Documents property to the supplied directory and creates a file in that directory.

public:
 System::Web::Services::Discovery::DiscoveryClientResultCollection ^ WriteAll(System::String ^ directory, System::String ^ topLevelFilename);
public System.Web.Services.Discovery.DiscoveryClientResultCollection WriteAll (string directory, string topLevelFilename);
member this.WriteAll : string * string -> System.Web.Services.Discovery.DiscoveryClientResultCollection
Public Function WriteAll (directory As String, topLevelFilename As String) As DiscoveryClientResultCollection

Parâmetros

directory
String

O diretório no qual salvar todos os documentos atualmente na propriedade Documents.The directory in which to save all documents currently in the Documents property.

topLevelFilename
String

O nome do arquivo a ser criado ou substituído contendo um mapa de todos os documentos salvos.The name of the file to create or overwrite containing a map of all documents saved.

Retornos

DiscoveryClientResultCollection

Um DiscoveryClientResultCollection que contém os resultados de todos os arquivos salvos.A DiscoveryClientResultCollection containing the results of all files saved.

Exemplos

O exemplo de código a seguir é um formulário da Web que grava os resultados de uma descoberta de serviços da Web em disco invocando o WriteAll método após chamadas para DiscoverAny e ResolveAll .The following code example is a Web Form that writes the results of a Web Services discovery to disk by invoking the WriteAll method after calls to DiscoverAny and ResolveAll.

 protected void Discover_Click(object Source, EventArgs e)
 {
  // Specify the URL to discover.
  string sourceUrl = DiscoURL.Text;
  // Specify the URL to save discovery results to or read from.
  string outputDirectory = DiscoDir.Text;

      DiscoveryClientProtocol client = new DiscoveryClientProtocol();
  // Use default credentials to access the URL being discovered.
      client.Credentials = CredentialCache.DefaultCredentials;

      try 
      {
        DiscoveryDocument doc;
        
        // Discover the URL for any discoverable documents. 
    doc = client.DiscoverAny(sourceUrl);
   
        // Resolve all possible references from the supplied URL.
        client.ResolveAll();
      }
      catch ( Exception e2) 
      {
        DiscoveryResultsGrid.Columns.Clear();
        Status.Text = e2.Message;
      }

  // Save the discovery results to disk.
      DiscoveryClientResultCollection results = client.WriteAll(outputDirectory, "results.discomap");
      Status.Text = "The following file holds the links to each of the discovery results: <b>" + 
                                  Path.Combine(outputDirectory,"results.discomap") + "</b>";
}
Public Sub Discover_Click(Source As Object, e as EventArgs )
   ' Specify the URL to discover.
   Dim sourceUrl as String = DiscoURL.Text
   ' Specify the URL to save discovery results to or read from.
   Dim outputDirectory As String = DiscoDir.Text

   Dim client as DiscoveryClientProtocol = new DiscoveryClientProtocol()
   ' Use default credentials to access the URL being discovered.
   client.Credentials = CredentialCache.DefaultCredentials
   Try 
     Dim doc As DiscoveryDocument
     ' Discover the URL for any discoverable documents. 
     doc = client.DiscoverAny(sourceUrl)

 ' Resolve all possible references from the supplied URL.
     client.ResolveAll()
           
    Catch e2 As Exception
       DiscoveryResultsGrid.Columns.Clear()
       Status.Text = e2.Message
    End Try

    ' Save the discovery results to disk.	    
    Dim results As DiscoveryClientResultCollection 
    results = client.WriteAll(outputDirectory, "results.discomap")
    Status.Text = "The following file holds the links to each of the discovery results: <b>" + _ 
                                  Path.Combine(outputDirectory,"results.discomap") + "</b>"
   End Sub

Comentários

O arquivo criado com o nome do topLevelFilename parâmetro no diretório especificado pelo parâmetro Directory contém um mapa de documentos de descoberta salvos, esquemas XSD (XML Schema Definition) e descrições de serviço.The file created with the name of the topLevelFilename parameter in the directory specified by the directory parameter contains a map of saved discovery documents, XML Schema Definition (XSD) schemas and service descriptions. Esse arquivo pode ser lido no usando o ReadAll método para preencher as References Documents Propriedades e.This file can be read in using the ReadAll method to populate the References and Documents properties. O formato do arquivo é XML que contém uma versão serializada da DiscoveryClientProtocol.DiscoveryClientResultsFile classe.The format of the file is XML containing an serialized version of the DiscoveryClientProtocol.DiscoveryClientResultsFile class.

Se existir um arquivo com o mesmo nome que o topLevelFilename parâmetro no directory parâmetro, esse arquivo será substituído pelo WriteAll método.If a file exists with the same name as the topLevelFilename parameter in the directory parameter, that file is overwritten by the WriteAll method. O topLevelFilename parâmetro deve incluir o caminho totalmente qualificado se o arquivo não existir no diretório atual.The topLevelFilename parameter must include the fully qualified path if the file does not exist in the current directory.

Aplica-se a

Confira também