2006-10-18 Atsushi Enomotot <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 18 Oct 2006 22:10:25 +0000 (22:10 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 18 Oct 2006 22:10:25 +0000 (22:10 -0000)
* SchemaReference.cs,
  DiscoveryClientProtocol.cs,
  ContractReference.cs: handle imported schemas in DiscoverAny().
  Fixed bug #78995.

svn path=/trunk/mcs/; revision=66806

mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Discovery/ContractReference.cs
mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryClientProtocol.cs
mcs/class/System.Web.Services/System.Web.Services.Discovery/SchemaReference.cs

index 7165edb4d9d31a1fa650a6b85696ab3de993bbce..8609364a1a4c42b307994608dc0bf1817acbde9e 100644 (file)
@@ -1,3 +1,10 @@
+2006-10-18  Atsushi Enomotot  <atsushi@ximian.com>
+
+       * SchemaReference.cs,
+         DiscoveryClientProtocol.cs,
+         ContractReference.cs: handle imported schemas in DiscoverAny().
+         Fixed bug #78995.
+
 2006-09-05  Lluis Sanchez Gual  <lluis@novell.com>
 
        * DiscoveryClientProtocol.cs: In ReadAll, load wsdl files from a
index 75fb86b568579ff2c0b88f9f68a089ce44ea55a9..925746467f1244b946db9d7c6ec00b1d55fe7211 100644 (file)
@@ -7,27 +7,27 @@
 //\r
 // Copyright (C) Dave Bettin, 2002\r
 //\r
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
+\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
 \r
 using System.IO;\r
 using System.Web.Services.Description;\r
@@ -148,6 +148,7 @@ namespace System.Web.Services.Discovery {
                                        string contentType = null;\r
                                        Stream stream = prot.Download (ref url, ref contentType);\r
                                        XmlTextReader reader = new XmlTextReader (url, stream);\r
+                                       reader.XmlResolver = null;\r
                                        reader.MoveToContent ();\r
                                        \r
                                        DiscoveryReference refe;\r
@@ -179,6 +180,18 @@ namespace System.Web.Services.Discovery {
                                        ReportError (url, ex);\r
                                }\r
                        }\r
+\r
+                       foreach (XmlSchema schema in wsdl.Types.Schemas)\r
+                       {\r
+                               // the schema itself is not added to the\r
+                               // references, but it has to resolve includes.\r
+                               Uri uri = BaseUri;\r
+                               string url = uri.ToString ();\r
+                               SchemaReference refe = new SchemaReference ();\r
+                               refe.ClientProtocol = prot;\r
+                               refe.Url = url;\r
+                               refe.ResolveInternal (prot, schema);\r
+                       }\r
                }\r
                 \r
         public override void WriteDocument (object document, Stream stream) \r
@@ -188,4 +201,4 @@ namespace System.Web.Services.Discovery {
 \r
                #endregion // Methods\r
        }\r
-}
+}\r
index d45bf066b3c2532b92300876ac2c0563f08cd668..28677d0d8623a7cfc4c10a01b5f62cd9639603d1 100644 (file)
@@ -85,6 +85,7 @@ namespace System.Web.Services.Discovery {
                {\r
                        Stream stream = Download (ref url);\r
                        XmlTextReader reader = new XmlTextReader (url, stream);\r
+                       reader.XmlResolver = null;\r
                        if (!DiscoveryDocument.CanRead (reader)) \r
                                throw new InvalidOperationException ("The url '" + url + "' does not point to a valid discovery document");\r
                                \r
@@ -135,6 +136,7 @@ namespace System.Web.Services.Discovery {
                                }\r
                                \r
                                XmlTextReader reader = new XmlTextReader (url, stream);\r
+                               reader.XmlResolver = null;\r
                                reader.MoveToContent ();\r
                                DiscoveryDocument doc;\r
                                DiscoveryReference refe = null;\r
@@ -162,6 +164,7 @@ namespace System.Web.Services.Discovery {
                                        documents.Add (url, schema);\r
                                        doc = new DiscoveryDocument ();\r
                                        refe = new SchemaReference ();\r
+                                       ((SchemaReference)refe).ResolveInternal (this, schema);\r
                                        doc.References.Add (refe);\r
                                }\r
                                \r
@@ -236,8 +239,8 @@ namespace System.Web.Services.Discovery {
                        StreamReader sr = new StreamReader (topLevelFilename);\r
                        XmlSerializer ser = new XmlSerializer (typeof (DiscoveryClientResultsFile));\r
                        DiscoveryClientResultsFile resfile = (DiscoveryClientResultsFile) ser.Deserialize (sr);\r
-                       sr.Close ();
-                       
+                       sr.Close ();\r
+                       \r
                        string basePath = Path.GetDirectoryName (topLevelFilename);\r
                        \r
                        foreach (DiscoveryClientResult dcr in resfile.Results)\r
index edb262e2ece7b557e4af2f22ce18ce6ffcbcd89d..e5f2cabe8dc1e161d84a42af4ec7949e2af95f01 100644 (file)
@@ -32,6 +32,7 @@
 \r
 using System.ComponentModel;\r
 using System.IO;\r
+using System.Xml;\r
 using System.Xml.Schema;\r
 using System.Xml.Serialization;\r
 \r
@@ -122,6 +123,51 @@ namespace System.Web.Services.Discovery {
                                ClientProtocol.References.Add (this);\r
                }\r
                 \r
+               internal void ResolveInternal (DiscoveryClientProtocol prot, XmlSchema xsd) \r
+               {\r
+                       if (xsd.Includes.Count == 0) return;\r
+                       \r
+                       foreach (XmlSchemaExternal ext in xsd.Includes)\r
+                       {\r
+                               if (ext.SchemaLocation == null)\r
+                                       continue;\r
+\r
+                               // Make relative uris to absoulte\r
+\r
+                               Uri uri = new Uri (BaseUri, ext.SchemaLocation);\r
+                               string url = uri.ToString ();\r
+\r
+                               if (prot.Documents.Contains (url))      // Already resolved\r
+                                       continue;\r
+\r
+                               try\r
+                               {\r
+                                       string contentType = null;\r
+                                       Stream stream = prot.Download (ref url, ref contentType);\r
+                                       XmlTextReader reader = new XmlTextReader (url, stream);\r
+                                       reader.XmlResolver = null;\r
+                                       reader.MoveToContent ();\r
+                                       \r
+                                       DiscoveryReference refe;\r
+                                       XmlSchema schema = XmlSchema.Read (reader, null);\r
+                                       refe = new SchemaReference ();\r
+                                       refe.ClientProtocol = prot;\r
+                                       refe.Url = url;\r
+                                       prot.Documents.Add (url, schema);\r
+                                       ((SchemaReference)refe).ResolveInternal (prot, schema);\r
+                                       \r
+                                       if (!prot.References.Contains (url))\r
+                                               prot.References.Add (refe);\r
+                                               \r
+                                       stream.Close ();\r
+                               }\r
+                               catch (Exception ex)\r
+                               {\r
+                                       ReportError (url, ex);\r
+                               }\r
+                       }\r
+               }\r
+\r
                public override void WriteDocument (object document, Stream stream) \r
                {\r
                        ((XmlSchema)document).Write (stream);\r