Author: atsushi
Date: 2006-10-18 18:10:25 -0400 (Wed, 18 Oct 2006)
New Revision: 66806

Modified:
   trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog
   
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ContractReference.cs
   
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryClientProtocol.cs
   
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/SchemaReference.cs
Log:
2006-10-18  Atsushi Enomotot  <[EMAIL PROTECTED]>

        * SchemaReference.cs,
          DiscoveryClientProtocol.cs,
          ContractReference.cs: handle imported schemas in DiscoverAny().
          Fixed bug #78995.



Modified: 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog 
2006-10-18 21:52:10 UTC (rev 66805)
+++ trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ChangeLog 
2006-10-18 22:10:25 UTC (rev 66806)
@@ -1,3 +1,10 @@
+2006-10-18  Atsushi Enomotot  <[EMAIL PROTECTED]>
+
+       * SchemaReference.cs,
+         DiscoveryClientProtocol.cs,
+         ContractReference.cs: handle imported schemas in DiscoverAny().
+         Fixed bug #78995.
+
 2006-09-05  Lluis Sanchez Gual  <[EMAIL PROTECTED]>
 
        * DiscoveryClientProtocol.cs: In ReadAll, load wsdl files from a

Modified: 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ContractReference.cs
===================================================================
--- 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ContractReference.cs
      2006-10-18 21:52:10 UTC (rev 66805)
+++ 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/ContractReference.cs
      2006-10-18 22:10:25 UTC (rev 66806)
@@ -7,28 +7,28 @@
 //
 // Copyright (C) Dave Bettin, 2002
 //
-
-//
-// 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.
-//
 
+//
+// 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.
+//
+
 using System.IO;
 using System.Web.Services.Description;
 using System.Xml.Serialization;
@@ -148,6 +148,7 @@
                                        string contentType = null;
                                        Stream stream = prot.Download (ref url, 
ref contentType);
                                        XmlTextReader reader = new 
XmlTextReader (url, stream);
+                                       reader.XmlResolver = null;
                                        reader.MoveToContent ();
                                        
                                        DiscoveryReference refe;
@@ -179,6 +180,18 @@
                                        ReportError (url, ex);
                                }
                        }
+
+                       foreach (XmlSchema schema in wsdl.Types.Schemas)
+                       {
+                               // the schema itself is not added to the
+                               // references, but it has to resolve includes.
+                               Uri uri = BaseUri;
+                               string url = uri.ToString ();
+                               SchemaReference refe = new SchemaReference ();
+                               refe.ClientProtocol = prot;
+                               refe.Url = url;
+                               refe.ResolveInternal (prot, schema);
+                       }
                }
                 
         public override void WriteDocument (object document, Stream stream) 
@@ -188,4 +201,4 @@
 
                #endregion // Methods
        }
-}
+}

Modified: 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryClientProtocol.cs
===================================================================
--- 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryClientProtocol.cs
        2006-10-18 21:52:10 UTC (rev 66805)
+++ 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/DiscoveryClientProtocol.cs
        2006-10-18 22:10:25 UTC (rev 66806)
@@ -85,6 +85,7 @@
                {
                        Stream stream = Download (ref url);
                        XmlTextReader reader = new XmlTextReader (url, stream);
+                       reader.XmlResolver = null;
                        if (!DiscoveryDocument.CanRead (reader)) 
                                throw new InvalidOperationException ("The url 
'" + url + "' does not point to a valid discovery document");
                                
@@ -135,6 +136,7 @@
                                }
                                
                                XmlTextReader reader = new XmlTextReader (url, 
stream);
+                               reader.XmlResolver = null;
                                reader.MoveToContent ();
                                DiscoveryDocument doc;
                                DiscoveryReference refe = null;
@@ -162,6 +164,7 @@
                                        documents.Add (url, schema);
                                        doc = new DiscoveryDocument ();
                                        refe = new SchemaReference ();
+                                       ((SchemaReference)refe).ResolveInternal 
(this, schema);
                                        doc.References.Add (refe);
                                }
                                
@@ -236,8 +239,8 @@
                        StreamReader sr = new StreamReader (topLevelFilename);
                        XmlSerializer ser = new XmlSerializer (typeof 
(DiscoveryClientResultsFile));
                        DiscoveryClientResultsFile resfile = 
(DiscoveryClientResultsFile) ser.Deserialize (sr);
-                       sr.Close ();
-                       
+                       sr.Close ();
+                       
                        string basePath = Path.GetDirectoryName 
(topLevelFilename);
                        
                        foreach (DiscoveryClientResult dcr in resfile.Results)

Modified: 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/SchemaReference.cs
===================================================================
--- 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/SchemaReference.cs
        2006-10-18 21:52:10 UTC (rev 66805)
+++ 
trunk/mcs/class/System.Web.Services/System.Web.Services.Discovery/SchemaReference.cs
        2006-10-18 22:10:25 UTC (rev 66806)
@@ -32,6 +32,7 @@
 
 using System.ComponentModel;
 using System.IO;
+using System.Xml;
 using System.Xml.Schema;
 using System.Xml.Serialization;
 
@@ -122,6 +123,51 @@
                                ClientProtocol.References.Add (this);
                }
                 
+               internal void ResolveInternal (DiscoveryClientProtocol prot, 
XmlSchema xsd) 
+               {
+                       if (xsd.Includes.Count == 0) return;
+                       
+                       foreach (XmlSchemaExternal ext in xsd.Includes)
+                       {
+                               if (ext.SchemaLocation == null)
+                                       continue;
+
+                               // Make relative uris to absoulte
+
+                               Uri uri = new Uri (BaseUri, ext.SchemaLocation);
+                               string url = uri.ToString ();
+
+                               if (prot.Documents.Contains (url))      // 
Already resolved
+                                       continue;
+
+                               try
+                               {
+                                       string contentType = null;
+                                       Stream stream = prot.Download (ref url, 
ref contentType);
+                                       XmlTextReader reader = new 
XmlTextReader (url, stream);
+                                       reader.XmlResolver = null;
+                                       reader.MoveToContent ();
+                                       
+                                       DiscoveryReference refe;
+                                       XmlSchema schema = XmlSchema.Read 
(reader, null);
+                                       refe = new SchemaReference ();
+                                       refe.ClientProtocol = prot;
+                                       refe.Url = url;
+                                       prot.Documents.Add (url, schema);
+                                       ((SchemaReference)refe).ResolveInternal 
(prot, schema);
+                                       
+                                       if (!prot.References.Contains (url))
+                                               prot.References.Add (refe);
+                                               
+                                       stream.Close ();
+                               }
+                               catch (Exception ex)
+                               {
+                                       ReportError (url, ex);
+                               }
+                       }
+               }
+
                public override void WriteDocument (object document, Stream 
stream) 
                {
                        ((XmlSchema)document).Write (stream);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to