共用方式為


DiscoveryClientProtocol.WriteAll(String, String) 方法

定義

將所有在 Documents 屬性中的探索文件、XML 結構描述定義 (XSD) 結構描述和服務描述寫入提供的目錄,並在該目錄中建立檔案。

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,包含所有已儲存檔案的結果。

範例

下列程式碼範例是 Web Form,它會在 呼叫 DiscoverAnyResolveAll 之後叫用 方法,將 Web 服務探索的結果寫入磁片 WriteAll

 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) 架構和服務描述。 您可以使用 方法來填 References 入 和 Documents 屬性, ReadAll 以讀取此檔案。 檔案的格式是 XML,其中包含 類別的 DiscoveryClientProtocol.DiscoveryClientResultsFile 序列化版本。

如果檔案與 參數中 directory 參數的名稱 topLevelFilename 相同,該方法就會覆寫 WriteAll 該檔案。 如果檔案不存在於目前目錄中,參數 topLevelFilename 必須包含完整路徑。

適用於

另請參閱