//\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
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
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
\r
#endregion // Methods\r
}\r
-}
+}\r
{\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
}\r
\r
XmlTextReader reader = new XmlTextReader (url, stream);\r
+ reader.XmlResolver = null;\r
reader.MoveToContent ();\r
DiscoveryDocument doc;\r
DiscoveryReference refe = null;\r
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
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
\r
using System.ComponentModel;\r
using System.IO;\r
+using System.Xml;\r
using System.Xml.Schema;\r
using System.Xml.Serialization;\r
\r
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