DiscoveryClientProtocol.WriteAll(String, String) Метод

Определение

Записывает все документы обнаружения, схемы определения схем XML (XSD) и описания служб из свойства Documents в указанный каталог и создает файл в этом каталоге.

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

Параметры

directory
String

Каталог, в который следует сохранить все документы, в текущий момент расположенные в свойстве Documents.

topLevelFilename
String

Имя создаваемого или перезаписываемого файла, содержащего карту всех сохраненных документов.

Возвращаемое значение

Класс DiscoveryClientResultCollection, содержащий результаты всех сохраненных файлов.

Примеры

Следующий пример кода представляет собой веб-форму, которая записывает результаты обнаружения веб-служб на диск путем вызова WriteAll метода после вызова DiscoverAny и 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

Комментарии

Файл, созданный с именем topLevelFilename параметра в каталоге, указанном параметром каталога, содержит карту сохраненных документов обнаружения, схем определения схемы XML (XSD) и описания служб. Этот файл можно считать в с помощью ReadAll метода для заполнения References свойств и Documents . Файл имеет формат XML, содержащий сериализованную версию DiscoveryClientProtocol.DiscoveryClientResultsFile класса .

Если существует файл с тем же именем topLevelFilename , что и параметр в параметре directory , этот файл перезаписывается методом WriteAll . Параметр topLevelFilename должен содержать полный путь, если файл не существует в текущем каталоге.

Применяется к

См. также раздел