5 // Lluis Sanchez Gual (lluis@ximian.com)
7 // Copyright (C) 2003 Ximian, Inc.
12 using System.Web.Services.Discovery;
17 static bool save = true;
18 static bool logo = true;
20 static string directory = ".";
21 static DiscoveryClientProtocol prot;
23 static void Main (string[] args)
27 ReadParameters (args);
32 if (args.Length == 0 || args[0] == "--help")
38 if (url == null) throw new Exception ("URL to discover not provided");
40 prot.DiscoverAny (url);
43 if (prot.References.Count > 0)
45 Console.WriteLine ("Disco found documents at the following URLs:");
46 foreach (DiscoveryReference refe in prot.References.Values)
48 if (refe is ContractReference) Console.Write ("- WSDL document at ");
49 else if (refe is DiscoveryDocumentReference) Console.Write ("- DISCO document at ");
50 else Console.Write ("- Xml Schema at ");
51 Console.WriteLine (refe.Url);
55 Console.WriteLine ("Disco didn't find any document at the specified URL");
59 DiscoveryClientResultCollection col = prot.WriteAll (directory, "results.discomap");
61 Console.WriteLine ("The following files hold the content found at the corresponding URLs:");
62 foreach (DiscoveryClientResult res in col)
63 Console.WriteLine ("- " + res.Filename + " <- " + res.Url);
65 Console.WriteLine ("The file " + Path.Combine (directory,"results.discomap") + " holds links to each of there files");
71 Console.WriteLine ("ERROR: " + ex.Message);
72 Console.WriteLine (ex);
76 static void WriteLogo ()
78 Console.WriteLine ("Mono Web Service Discovery Tool");
82 static void WriteHelp ()
84 Console.WriteLine ("Usage: disco [options] url");
86 Console.WriteLine ("Options:");
87 Console.WriteLine (" -nologo Supress the startup logo");
88 Console.WriteLine (" -nosave Do not save the discovered documents to disk.");
89 Console.WriteLine (" The default is to save the documents.");
90 Console.WriteLine (" -o -out:directory The directory where to save the discovered documents.");
91 Console.WriteLine (" By default, documents are saved in the current");
92 Console.WriteLine (" directory.");
93 Console.WriteLine (" -u -username:username ");
94 Console.WriteLine (" -p -password:password ");
95 Console.WriteLine (" -d -domain:domain The credentials to use when connecting to the server.");
96 Console.WriteLine (" -proxy:url The url of the proxy server to use for http requests.");
97 Console.WriteLine (" -proxyusername:name");
98 Console.WriteLine (" -proxypassword:pwd");
99 Console.WriteLine (" -proxydomin:domain The credentials to use when connection to the proxy.");
100 Console.WriteLine ();
103 static void ReadParameters (string[] args)
105 prot = new DiscoveryClientProtocol ();
106 NetworkCredential cred = new NetworkCredential ();
107 NetworkCredential proxyCred = new NetworkCredential ();
108 WebProxy proxy = new WebProxy ();
111 foreach (string arg in args)
113 if (arg.StartsWith ("/") || arg.StartsWith ("-"))
115 string parg = arg.Substring (1);
116 int i = parg.IndexOf (":");
119 param = parg.Substring (i+1);
120 parg = parg.Substring (0,i);
133 case "out": case "o":
137 case "username": case "u":
138 cred.UserName = param;
141 case "password": case "p":
142 cred.Password = param;
145 case "domain": case "d":
150 proxy.Address = new Uri (param);
153 case "proxyusername":
154 proxyCred.UserName = param;
157 case "proxypassword":
158 proxyCred.Password = param;
162 proxyCred.Domain = param;
166 if (cred.UserName != null)
167 prot.Credentials = cred;
169 if (proxyCred.UserName != null)
170 proxy.Credentials = proxyCred;
172 if (proxy.Address != null)