C# Example |
Top Previous Next |
Generating the Proxy Class
Included as part of the .Net Framework tools is the Web Services Description Language Tool (Wsdl.exe). Using Wsdl.exe, you can create a C# proxy class which can be used to communicate with the FinalBuilder Server web services.
Usage:
wsdl.exe /n:[namespace] /o:[output_file] [build_machine]/Services/FinalBuilderServer.asmx?wsdl
Substituting the following:
[namespace] - The namespace that the generated source file should have. [output_file] - The location where you want the source file to be generated. [build_machine] - The URL to machine hosting FinalBuilder Server, including the virtual directory if applicable.
For example: wsdl.exe /n:"VSoft" /o:"C:\Proxy.cs" http://MyBuildVM/Services/FinalBuilderServer.asmx?wsdl
Using the Generated Proxy Class
You will need to add the proxy class to your C# project and include a reference to 'System.Web.Services'.
using System; using VSoft;
namespace WebService.Sample { public class Program { public static void Main(string[] args) { // Instantiate the FinalBuilder Server Proxy Class. FinalBuilderServer server = new FinalBuilderServer();
// Authenticate the user. string authToken = server.Authenticate("paul", "my_password");
// Get the list of all projects configured on this build server. string[] projectNames = server.GetProjectNames(authToken);
foreach (string projectName in projectNames) { // Get the status of the project ProjectStatus status = server.GetProjectStatus(authToken, projectName); Console.WriteLine("Project '{0}' state is currently '{1}'.", projectName, status);
// Get the trigger log of the project string[] log = server.GetProjectTriggerLog(authToken, projectName); Console.WriteLine("Project '{0}' Trigger Log:", projectName);
foreach (string line in log) { Console.WriteLine(line); } }
Console.ReadLine(); } } } |