Merge pull request #1296 from directhex/master
[mono.git] / mcs / tools / wsdl / MonoWSDL.cs
index a5b2d67df51a79aeafb96858f647c8c6a965ba88..430b225329d1e6d533d9fd206a04752b82574306 100644 (file)
@@ -10,6 +10,7 @@
 #if !NET_2_0\r
 \r
 using System;\r
+using System.Collections.Specialized;\r
 using System.Xml;\r
 using System.Xml.Schema;\r
 using System.Collections;\r
@@ -306,7 +307,7 @@ namespace Mono.WebServices
                string password;\r
                string domain;\r
                \r
-               string url;\r
+               StringCollection urls = new StringCollection ();\r
                string className;\r
 \r
                ///\r
@@ -340,7 +341,7 @@ namespace Mono.WebServices
                        else\r
                        {\r
                                hasURL = true;\r
-                               url = argument;\r
+                               urls.Add (argument);\r
                                return;\r
                        }\r
                        \r
@@ -448,7 +449,7 @@ namespace Mono.WebServices
                                default:\r
                                        if (argument.StartsWith ("/") && argument.IndexOfAny (Path.InvalidPathChars) == -1) {\r
                                                hasURL = true;\r
-                                               url = argument;\r
+                                               urls.Add (argument);\r
                                                break;\r
                                        }\r
                                        else\r
@@ -527,30 +528,31 @@ namespace Mono.WebServices
                                        return 0;\r
                                }\r
                                \r
-                               if (className == null)\r
-                               {\r
+                               if (className == null) {\r
                                        DiscoveryClientProtocol dcc = CreateClient ();\r
-                                       dcc.AllowAutoRedirect = true;\r
-                                                                       \r
-                                       if (!url.StartsWith ("http://") && !url.StartsWith ("https://") && !url.StartsWith ("file://"))\r
-                                               url = new Uri (Path.GetFullPath (url)).ToString ();\r
-                                               \r
-                                       dcc.DiscoverAny (url);\r
-                                       dcc.ResolveAll ();\r
-                                       \r
-                                       foreach (object doc in dcc.Documents.Values)\r
-                                       {\r
+\r
+                                       foreach (string urlEntry in urls) {\r
+                                               string url = urlEntry;\r
+                                               dcc.AllowAutoRedirect = true;\r
+                                               if (!url.StartsWith ("http://") && !url.StartsWith ("https://") && !url.StartsWith ("file://"))\r
+                                                       url = new Uri (Path.GetFullPath (url)).ToString ();\r
+                                                       \r
+                                               dcc.DiscoverAny (url);\r
+                                               dcc.ResolveAll ();\r
+                                       }\r
+\r
+                                       foreach (object doc in dcc.Documents.Values) {\r
                                                if (doc is ServiceDescription)\r
-                                                       descriptions.Add ((ServiceDescription)doc);\r
+                                                       descriptions.Add ((ServiceDescription) doc);\r
                                                else if (doc is XmlSchema)\r
-                                                       schemas.Add ((XmlSchema)doc);\r
+                                                       schemas.Add ((XmlSchema) doc);\r
                                        }\r
-                                       \r
-                                       if (descriptions.Count == 0)\r
-                                               throw new Exception ("No WSDL document was found at the url " + url);\r
-                               }\r
-                               else\r
-                               {\r
+\r
+                                       if (descriptions.Count == 0) {\r
+                                               Console.WriteLine ("Warning: no classes were generated.");\r
+                                               return 0;\r
+                                       }\r
+                               } else {\r
                                        string[] names = className.Split (',');\r
                                        if (names.Length != 2) throw new Exception ("Invalid parameter value for 'type'");\r
                                        string cls = names[0].Trim ();\r
@@ -560,7 +562,8 @@ namespace Mono.WebServices
                                        Type t = asm.GetType (cls);\r
                                        if (t == null) throw new Exception ("Type '" + cls + "' not found in assembly " + assembly);\r
                                        ServiceDescriptionReflector reflector = new ServiceDescriptionReflector ();\r
-                                       reflector.Reflect (t, url);\r
+                                       foreach (string url in urls)\r
+                                               reflector.Reflect (t, url);\r
                                        foreach (XmlSchema s in reflector.Schemas)\r
                                                schemas.Add (s);\r
                                                \r