DiscoveryClientProtocol.WriteAll(String, String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 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
参数
- topLevelFilename
- String
要创建或覆盖的文件的名称,该文件包含所有已保存的文档的映射。
返回
包含所有已保存文件的结果的 DiscoveryClientResultCollection。
示例
下面的代码示例是一个 Web 窗体,它通过在调用和ResolveAll调用DiscoverAny后调用WriteAll该方法,将 Web 服务发现的结果写入磁盘。
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此文件。 文件的格式是包含类的 DiscoveryClientProtocol.DiscoveryClientResultsFile 序列化版本的 XML。
如果某个文件与参数中directory
参数的名称topLevelFilename
相同,该方法将覆盖WriteAll该文件。 如果当前目录中不存在文件,该 topLevelFilename
参数必须包含完全限定的路径。