Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DiscoveryClientProtocol.WriteAll Method

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.

[Visual Basic]
Public Function WriteAll( _
   ByVal directory As String, _
   ByVal topLevelFilename As String _
) As DiscoveryClientResultCollection
[C#]
public DiscoveryClientResultCollection WriteAll(
 string directory,
 string topLevelFilename
);
[C++]
public: DiscoveryClientResultCollection* WriteAll(
 String* directory,
 String* topLevelFilename
);
[JScript]
public function WriteAll(
   directory : String,
 topLevelFilename : String
) : DiscoveryClientResultCollection;

Parameters

directory
The directory in which to save all documents currently in the Documents property.
topLevelFilename
The name of the file to create or overwrite containing a map of all documents saved.

Return Value

A DiscoveryClientResultCollection containing the results of all files saved.

Remarks

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. This file can be read in using the ReadAll method to populate the References and Documents properties. The format of the file is XML containing an serialized version of the DiscoveryClientProtocol.DiscoveryClientResultsFile class.

If a file exists with the same name as the topLevelFilename parameter in the directory parameter, that file is overwritten by the WriteAll method. The topLevelFilename parameter must include the fully qualified path if the file does not exist in the current directory.

Example

[Visual Basic, C#] 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.

[Visual Basic] 
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

[C#] 
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>";
  }

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.