Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,206 @@
2007-11-01 Atsushi Enomotot <atsushi@ximian.com>
* DiscoveryClientProtocol.cs : without setting Url before resolve,
it causes NRE on get_BaseUrl().
2007-10-05 Atsushi Enomotot <atsushi@ximian.com>
* DiscoveryClientProtocol.cs : [ComVisible]
2007-08-31 Gert Driesen <drieseng@users.sourceforge.net>
* DiscoveryRequestHandler.cs: Do not require write access to file.
2006-11-15 Atsushi Enomotot <atsushi@ximian.com>
* DiscoveryReference.cs: FilenameFromUrl() is public.
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
path relative to the .map file.
2005-08-15 Gert Driesen <drieseng@users.sourceforge.net>
* SchemaReference.cs: DefaultValue of TargetNamespace should be null.
* DiscoveryClientProtocol.cs: Added LoadExternals method to match
MS.NET. Fixed line endings.
2005-08-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* DiscoveryClientProtocol.cs: use Uri so that relative paths are handled
gracefully.
2005-05-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* SchemaReference.cs: fixed the setter for TargetNamespace.
2004-09-01 Lluis Sanchez Gual <lluis@novell.com>
* DiscoveryClientProtocol.cs: Added support for "file://" urls.
2004-08-24 Lluis Sanchez Gual <lluis@novell.com>
* ContractReference.cs, DiscoveryClientProtocol.cs: Set the url from which
documents are being read.
2004-06-13 Gert Driesen <drieseng@users.sourceforge.net>
* SchemaReference.cs: corrected namespace
* SoapBinding.cs: corrected namespace
2004-06-10 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryClientProtocol.cs: In DiscoverAny, catch expection of type
DiscoveryException and rethrow the included Exception instead.
* DiscoveryReference.cs: Added BaseUri property, that returns an uri
for the reference, supporting file uris.
* ContractReference.cs: Use the new property BaseUri to build the import
uri.
2004-06-01 Gert Driesen <drieseng@users.sourceforge.net>
* DiscoveryReference.cs: Added missing XmlIgnore attribute.
2004-05-24 Lluis Sanchez Gual <lluis@ximian.com>
* ContractReference.cs: convert relative import uris to absolute uris.
* DiscoveryClientProtocol.cs: Before resolving a reference, always
set the Url property.
2004-03-10 Lluis Sanchez Gual <lluis@ximian.com>
* ContractReference.cs, DiscoveryDocumentReference.cs: Delegate handling
of errors to the base class.
* ContractSearchPattern.cs, DiscoveryDocumentLinksPattern.cs,
DiscoveryDocumentSearchPattern.cs, XmlSchemaSearchPattern.cs: Implemented.
* DiscoveryClientProtocol.cs: Do not throw exceptions in ResolveAll method,
rather add them to the errors list.
* DiscoveryReference.cs: Generate DiscoveryException where needed, so
DiscoveryClientProtocol can get the url for which an exception was thrown.
* DiscoveryExceptionDictionary.cs: Implemented.
2004-03-10 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryClientProtocol.cs: Read additional information (such as soap
bindings) from the discovery documents.
* DiscoveryDocument.cs: Added support for additional discovery information.
* DiscoveryDocumentSerializer.cs: Updated serializer, added support for
soap bindings.
2004-03-02 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryClientProtocol.cs: Now it can get alternate urls from HTML pages
that include a link tag. Added support for loading files from a the
file system.
2004-01-24 Lluis Sanchez Gual <lluis@ximian.com>
* ContractReference.cs, DiscoveryClientProtocol.cs,
DiscoveryDocumentReference.cs: When resolving a wsdl document, recursively
resolve the documents it imports.
2003-12-19 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryDocument.cs: Set namespace for ContractReference references.
Write() methods: Added namespace declaration in serializer.
* DiscoveryDocumentSerializer.cs: Fixed namespace for ContractReference.
* DiscoveryRequestHandler.cs: Implemented.
* DynamicDiscoveryDocument.cs: Implemented.
* ExcludePathInfo.cs, SoapBinding.cs: Removed some TODOs
2003-12-12 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryReference.cs: In FilenameFromUrl(), improved name generation
for some common cases.
2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryDocumentSerializer.cs: The class must be internal.
2003-10-21 Lluis Sanchez Gual <lluis@ximian.com>
* DiscoveryClientProtocol.cs: Fixed little bug in DiscoverAny.
2003-10-13 Lluis Sanchez Gual <lluis@ximian.com>
* ContractReference.cs, DiscoveryDocumentReference.cs, SchemaReference.cs:
Little fixes.
* DiscoveryClientProtocol.cs: WriteAll(): Write files to the provided
directory.
* DiscoveryReference.cs: Improved method FilenameFromUrl().
2003-10-10 Lluis Sanchez Gual <lluis@ximian.com>
* ContractReference.cs, DiscoveryClientProtocol.cs,
DiscoveryClientResult.cs, DiscoveryDocument.cs,
DiscoveryDocumentReference.cs, DiscoveryExceptionDictionary.cs,
DiscoveryReference.cs, SchemaReference.cs: Implemented initial support
for discovery documents (.disco).
2002-08-19 Tim Coleman <tim@timcoleman.com>
* DiscoveryClientProtocol.cs:
Added ResolveAll () stub.
* DiscoveryDocument.cs:
Added XmlRoot attribute to class.
* DiscoveryClientDocumentCollection.cs:
* DiscoveryClientReferenceCollection.cs:
* DiscoveryClientResultCollection.cs:
* DiscoveryReferenceCollection.cs:
Implementation of these classes.
2002-08-04 Dave Bettin <javabettin@yahoo.com>
* ContractSearchPattern.cs
* DiscoveryClientDocumentCollection.cs
* DiscoveryClientProtocol.cs
* DiscoveryClientResult.cs
* DiscoveryDocument.cs
* DiscoveryDocumentLinksPattern.cs
* DiscoveryDocumentReference.cs
* DiscoveryDocumentSearchPattern.cs
* DiscoveryReference.cs
* DiscoveryRequestHandler.cs
* DiscoverySearchPattern.cs
* DynamicDiscoveryDocument.cs
* SchemaReference.cs
* SoapBinding.cs
* XmlSchemaSearchPattern.cs
[ Added attributes and some basic implementation]
2002-08-03 Tim Coleman <tim@timcoleman.com>
* DiscoveryDocument.cs:
Added XmlIgnore attribute to References property
* DiscoveryDocumentReference.cs:
Implemented Ref/Url properties and added XmlIgnore
attributes.
2002-07-28 Dave Bettin <javabettin@yahoo.com>
* ContractReference.cs
* ContractSearchPattern.cs
* DiscoveryClientDocumentCollection.cs
* DiscoveryClientProtocol.cs
* DiscoveryClientReferenceCollection.cs
* DiscoveryClientResultCollection.cs
* DiscoveryClientResult.cs
* DiscoveryDocument.cs
* DiscoveryDocumentLinksPattern.cs
* DiscoveryDocumentReference.cs
* DiscoveryDocumentSearchPattern.cs
* DiscoveryExceptionDictionary.cs
* DiscoveryReferenceCollection.cs
* DiscoveryReference.cs
* DiscoveryRequestHandler.cs
* DiscoverySearchPattern.cs
* DynamicDiscoveryDocument.cs
* ExcludePathInfo.cs
* SchemaReference.cs
* SoapBinding.cs
* XmlSchemaSearchPattern.cs
[ Added stubs]

View File

@@ -0,0 +1,204 @@
//
// System.Web.Services.Discovery.ContractReference.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.IO;
using System.Web.Services.Description;
using System.Xml.Serialization;
using System.Xml;
using System.Xml.Schema;
namespace System.Web.Services.Discovery {
[XmlRootAttribute("contractRef", Namespace="http://schemas.xmlsoap.org/disco/scl/", IsNullable=true)]
public class ContractReference : DiscoveryReference {
#region Fields
public const string Namespace = "http://schemas.xmlsoap.org/disco/scl/";
private ServiceDescription contract;
private string defaultFilename;
private string docRef;
private string href;
#endregion // Fields
#region Constructors
public ContractReference ()
{
}
public ContractReference (string href) : this()
{
this.href = href;
}
public ContractReference (string href, string docRef)
{
this.href = href;
this.docRef = docRef;
}
#endregion // Constructors
#region Properties
[XmlIgnore]
public ServiceDescription Contract {
get {
if (ClientProtocol == null)
throw new InvalidOperationException ("The ClientProtocol property is a null reference");
ServiceDescription desc = ClientProtocol.Documents [Url] as ServiceDescription;
if (desc == null)
throw new Exception ("The Documents property of ClientProtocol does not contain a WSDL document with the url " + Url);
return desc;
}
}
[XmlIgnore]
public override string DefaultFilename {
get { return FilenameFromUrl (Url) + ".wsdl"; }
}
[XmlAttribute("docRef")]
public string DocRef {
get { return docRef; }
set { docRef = value; }
}
[XmlAttribute("ref")]
public string Ref {
get { return href; }
set { href = value; }
}
[XmlIgnore]
public override string Url {
get { return href;}
set { href = value; }
}
#endregion // Properties
#region Methods
public override object ReadDocument (Stream stream)
{
return ServiceDescription.Read (stream);
}
protected internal override void Resolve (string contentType, Stream stream)
{
ServiceDescription wsdl = ServiceDescription.Read (stream);
if (!ClientProtocol.References.Contains (Url))
ClientProtocol.References.Add (this);
ClientProtocol.Documents.Add (Url, wsdl);
ResolveInternal (ClientProtocol, wsdl);
}
internal void ResolveInternal (DiscoveryClientProtocol prot, ServiceDescription wsdl)
{
if (wsdl.Imports == null) return;
foreach (Import import in wsdl.Imports)
{
// Make relative uris to absoulte
Uri uri = new Uri (BaseUri, import.Location);
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;
if (ServiceDescription.CanRead (reader))
{
ServiceDescription refWsdl = ServiceDescription.Read (reader);
refe = new ContractReference ();
refe.ClientProtocol = prot;
refe.Url = url;
((ContractReference)refe).ResolveInternal (prot, refWsdl);
prot.Documents.Add (url, refWsdl);
}
else
{
XmlSchema schema = XmlSchema.Read (reader, null);
refe = new SchemaReference ();
refe.ClientProtocol = prot;
refe.Url = url;
prot.Documents.Add (url, schema);
}
if (!prot.References.Contains (url))
prot.References.Add (refe);
reader.Close ();
}
catch (Exception ex)
{
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)
{
((ServiceDescription)document).Write (stream);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,70 @@
//
// System.Web.Services.Protocols.ContractSearchPattern.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
namespace System.Web.Services.Discovery {
public sealed class ContractSearchPattern : DiscoverySearchPattern {
#region Fields
private string pattern = "*.asmx";
#endregion // Fields
#region Constructors
public ContractSearchPattern ()
{
}
#endregion // Constructors
#region Properties
public override string Pattern {
get { return pattern; }
}
#endregion // Properties
#region Methods
public override DiscoveryReference GetDiscoveryReference (string filename)
{
ContractReference refe = new ContractReference ();
refe.Url = filename;
refe.Ref = filename;
refe.DocRef = filename;
return refe;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,87 @@
//
// System.Web.Services.Discovery.DiscoveryClientDocumentCollection.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Dave Bettin, 2002
// Copyright (C) Tim Coleman, 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.
//
using System.Collections;
namespace System.Web.Services.Discovery {
public sealed class DiscoveryClientDocumentCollection : DictionaryBase {
#region Constructors
public DiscoveryClientDocumentCollection ()
: base ()
{
}
#endregion // Constructors
#region Properties
public object this [string url] {
get { return InnerHashtable [url]; }
set {
if (url == null)
throw new ArgumentNullException ();
InnerHashtable [url] = value;
}
}
public ICollection Keys {
get { return InnerHashtable.Keys; }
}
public ICollection Values {
get { return InnerHashtable.Values; }
}
#endregion // Properties
#region Methods
public void Add (string url, object value)
{
InnerHashtable [url] = value;
}
public bool Contains (string url)
{
return InnerHashtable.Contains (url);
}
public void Remove (string url)
{
InnerHashtable.Remove (url);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,388 @@
//
// System.Web.Services.Protocols.DiscoveryClientProtocol.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.Collections;
using System.IO;
using System.Web.Services.Protocols;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Net;
using System.Text.RegularExpressions;
#if !MOBILE
using System.Web.Services.Description;
#endif
namespace System.Web.Services.Discovery {
public class DiscoveryClientProtocol : HttpWebClientProtocol {
#region Fields
private IList additionalInformation = new ArrayList ();
private DiscoveryClientDocumentCollection documents = new DiscoveryClientDocumentCollection();
private DiscoveryExceptionDictionary errors = new DiscoveryExceptionDictionary();
private DiscoveryClientReferenceCollection references = new DiscoveryClientReferenceCollection();
#endregion // Fields
#region Constructors
public DiscoveryClientProtocol ()
{
}
#endregion // Constructors
#region Properties
public IList AdditionalInformation {
get { return additionalInformation; }
}
public DiscoveryClientDocumentCollection Documents {
get { return documents; }
}
public DiscoveryExceptionDictionary Errors {
get { return errors; }
}
public DiscoveryClientReferenceCollection References {
get { return references; }
}
#endregion // Properties
#region Methods
public DiscoveryDocument Discover (string url)
{
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");
DiscoveryDocument doc = DiscoveryDocument.Read (reader);
reader.Close ();
documents.Add (url, doc);
AddDiscoReferences (doc);
return doc;
}
public DiscoveryDocument DiscoverAny (string url)
{
try
{
string contentType = null;
Stream stream = Download (ref url, ref contentType);
if (contentType.IndexOf ("text/html") != -1)
{
// Look for an alternate url
StreamReader sr = new StreamReader (stream);
string str = sr.ReadToEnd ();
string rex = "link\\s*rel\\s*=\\s*[\"']?alternate[\"']?\\s*";
rex += "type\\s*=\\s*[\"']?text/xml[\"']?\\s*href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|'(?<1>[^']*)'|(?<1>\\S+))";
Regex rob = new Regex (rex, RegexOptions.IgnoreCase);
Match m = rob.Match (str);
if (!m.Success)
throw new InvalidOperationException ("The HTML document does not contain Web service discovery information");
if (url.StartsWith ("/"))
{
Uri uri = new Uri (url);
url = uri.GetLeftPart (UriPartial.Authority) + m.Groups[1];
}
else
{
int i = url.LastIndexOf ('/');
if (i == -1)
throw new InvalidOperationException ("The HTML document does not contain Web service discovery information");
Uri tmp = new Uri (url);
tmp = new Uri (tmp, m.Groups [1].ToString ());
url = tmp.ToString ();
}
stream = Download (ref url);
}
XmlTextReader reader = new XmlTextReader (url, stream);
reader.XmlResolver = null;
reader.MoveToContent ();
DiscoveryDocument doc;
DiscoveryReference refe = null;
if (DiscoveryDocument.CanRead (reader))
{
doc = DiscoveryDocument.Read (reader);
documents.Add (url, doc);
refe = new DiscoveryDocumentReference ();
AddDiscoReferences (doc);
}
#if !MOBILE
else if (ServiceDescription.CanRead (reader))
{
ServiceDescription wsdl = ServiceDescription.Read (reader);
documents.Add (url, wsdl);
doc = new DiscoveryDocument ();
refe = new ContractReference ();
doc.References.Add (refe);
refe.Url = url;
((ContractReference)refe).ResolveInternal (this, wsdl);
}
#endif
else
{
XmlSchema schema = XmlSchema.Read (reader, null);
documents.Add (url, schema);
doc = new DiscoveryDocument ();
refe = new SchemaReference ();
refe.Url = url;
((SchemaReference)refe).ResolveInternal (this, schema);
doc.References.Add (refe);
}
refe.ClientProtocol = this;
refe.Url = url;
references.Add (url, refe);
reader.Close ();
return doc;
}
catch (DiscoveryException ex) {
throw ex.Exception;
}
}
void AddDiscoReferences (DiscoveryDocument doc)
{
foreach (DiscoveryReference re in doc.References)
{
re.ClientProtocol = this;
references.Add (re.Url, re);
}
if (doc.AdditionalInfo != null) {
foreach (object info in doc.AdditionalInfo)
additionalInformation.Add (info);
}
}
public Stream Download (ref string url)
{
string contentType = null;
return Download (ref url, ref contentType);
}
public Stream Download (ref string url, ref string contentType)
{
if (url.StartsWith ("http://") || url.StartsWith ("https://"))
{
WebRequest request = GetWebRequest (new Uri(url));
WebResponse resp = request.GetResponse ();
contentType = resp.ContentType;
return resp.GetResponseStream ();
}
else if (url.StartsWith ("file://"))
{
WebRequest request = WebRequest.Create (new Uri (url));
WebResponse resp = request.GetResponse ();
contentType = resp.ContentType;
return resp.GetResponseStream ();
}
else
{
string ext = Path.GetExtension (url).ToLower();
if (ext == ".wsdl" || ext == ".xsd")
{
contentType = "text/xml";
return new FileStream (url, FileMode.Open, FileAccess.Read);
}
else
throw new InvalidOperationException ("Unrecognized file type '" + url + "'. Extension must be one of .wsdl or .xsd");
}
}
#if NET_2_0
[System.Runtime.InteropServices.ComVisible (false)]
#endif
[Obsolete ("This method will be removed from a future version. The method call is no longer required for resource discovery", false)]
public void LoadExternals ()
{
}
public DiscoveryClientResultCollection ReadAll (string topLevelFilename)
{
StreamReader sr = new StreamReader (topLevelFilename);
XmlSerializer ser = new XmlSerializer (typeof (DiscoveryClientResultsFile));
DiscoveryClientResultsFile resfile = (DiscoveryClientResultsFile) ser.Deserialize (sr);
sr.Close ();
string basePath = Path.GetDirectoryName (topLevelFilename);
foreach (DiscoveryClientResult dcr in resfile.Results)
{
Type type = Type.GetType (dcr.ReferenceTypeName);
DiscoveryReference dr = (DiscoveryReference) Activator.CreateInstance (type);
dr.Url = dcr.Url;
FileStream fs = new FileStream (Path.Combine (basePath, dcr.Filename), FileMode.Open, FileAccess.Read);
Documents.Add (dr.Url, dr.ReadDocument (fs));
fs.Close ();
References.Add (dr.Url, dr);
}
return resfile.Results;
}
public void ResolveAll ()
{
ArrayList list = new ArrayList (References.Values);
foreach (DiscoveryReference re in list)
{
try
{
if (re is DiscoveryDocumentReference)
((DiscoveryDocumentReference)re).ResolveAll ();
else
re.Resolve ();
}
catch (DiscoveryException ex)
{
Errors [ex.Url] = ex.Exception;
}
catch (Exception ex)
{
Errors [re.Url] = ex;
}
}
}
public void ResolveOneLevel ()
{
ArrayList list = new ArrayList (References.Values);
foreach (DiscoveryReference re in list)
re.Resolve ();
}
public DiscoveryClientResultCollection WriteAll (string directory, string topLevelFilename)
{
DiscoveryClientResultsFile resfile = new DiscoveryClientResultsFile();
foreach (DiscoveryReference re in References.Values)
{
object doc = Documents [re.Url];
if (doc == null) continue;
string fileName = FindValidName (resfile, re.DefaultFilename);
resfile.Results.Add (new DiscoveryClientResult (re.GetType(), re.Url, fileName));
string filepath = Path.Combine (directory, fileName);
FileStream fs = new FileStream (filepath, FileMode.Create, FileAccess.Write);
re.WriteDocument (doc, fs);
fs.Close ();
}
StreamWriter sw = new StreamWriter (Path.Combine (directory, topLevelFilename));
XmlSerializer ser = new XmlSerializer (typeof (DiscoveryClientResultsFile));
ser.Serialize (sw, resfile);
sw.Close ();
return resfile.Results;
}
string FindValidName (DiscoveryClientResultsFile resfile, string baseName)
{
string name = baseName;
int id = 0;
bool found;
do
{
found = false;
foreach (DiscoveryClientResult res in resfile.Results)
{
if (name == res.Filename) {
found = true; break;
}
}
if (found)
name = Path.GetFileNameWithoutExtension (baseName) + (++id) + Path.GetExtension (baseName);
}
while (found);
return name;
}
#endregion // Methods
#region Classes
public sealed class DiscoveryClientResultsFile {
#region Fields
private DiscoveryClientResultCollection results;
#endregion // Fields
#region Contructors
public DiscoveryClientResultsFile ()
{
results = new DiscoveryClientResultCollection ();
}
#endregion // Constructors
#region Properties
public DiscoveryClientResultCollection Results {
get { return results; }
}
#endregion // Properties
}
#endregion // Classes
}
internal class DiscoveryException : Exception
{
public string Url;
public Exception Exception;
public DiscoveryException (string url, Exception origin)
{
Url = url;
Exception = origin;
}
}
}

View File

@@ -0,0 +1,88 @@
//
// System.Web.Services.Protocols.DiscoveryClientReferenceCollection.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Dave Bettin, 2002
// Copyright (C) Tim Coleman, 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.
//
using System.Collections;
namespace System.Web.Services.Discovery {
public sealed class DiscoveryClientReferenceCollection : DictionaryBase {
#region Constructors
public DiscoveryClientReferenceCollection ()
: base ()
{
}
#endregion // Constructors
#region Properties
public DiscoveryReference this [string url] {
get { return (DiscoveryReference) InnerHashtable [url]; }
set { InnerHashtable [url] = value; }
}
public ICollection Keys {
get { return InnerHashtable.Keys; }
}
public ICollection Values {
get { return InnerHashtable.Values; }
}
#endregion // Properties
#region Methods
public void Add (DiscoveryReference value)
{
Add (value.Url, value);
}
public void Add (string url, DiscoveryReference value)
{
InnerHashtable [url] = value;
}
public bool Contains (string url)
{
return InnerHashtable.Contains (url);
}
public void Remove (string url)
{
InnerHashtable.Remove (url);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,83 @@
//
// System.Web.Services.Disocvery.DiscoveryClientResult.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.Xml.Serialization;
namespace System.Web.Services.Discovery {
public sealed class DiscoveryClientResult {
#region Fields
private string filename;
private string referenceTypeName;
private string url;
#endregion // Fields
#region Constructors
public DiscoveryClientResult ()
{
}
public DiscoveryClientResult (Type referenceType, string url, string filename) : this()
{
this.filename = filename;
this.url = url;
this.referenceTypeName = referenceType.FullName;
}
#endregion // Constructors
#region Properties
[XmlAttribute("filename")]
public string Filename {
get { return filename; }
set { filename = value; }
}
[XmlAttribute("referenceType")]
public string ReferenceTypeName {
get { return referenceTypeName; }
set { referenceTypeName = value; }
}
[XmlAttribute("url")]
public string Url {
get { return url; }
set { url = value; }
}
#endregion // Properties
}
}

View File

@@ -0,0 +1,83 @@
//
// System.Web.Services.Protocols.DiscoveryClientResultCollection.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Dave Bettin, 2002
// Copyright (C) Tim Coleman, 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.
//
using System.Collections;
namespace System.Web.Services.Discovery {
public sealed class DiscoveryClientResultCollection : CollectionBase {
#region Constructors
public DiscoveryClientResultCollection ()
: base ()
{
}
#endregion // Constructors
#region Properties
public DiscoveryClientResult this [int i] {
get {
if (i < 0 || i >= Count)
throw new ArgumentOutOfRangeException ();
return (DiscoveryClientResult) InnerList [i];
}
set {
if (i < 0 || i >= Count)
throw new ArgumentOutOfRangeException ();
InnerList [i] = value;
}
}
#endregion // Properties
#region Methods
public int Add (DiscoveryClientResult value)
{
return InnerList.Add (value);
}
public bool Contains (DiscoveryClientResult value)
{
return InnerList.Contains (value);
}
public void Remove (DiscoveryClientResult value)
{
InnerList.Remove (value);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,157 @@
//
// System.Web.Services.Protocols.DiscoveryDocument.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Tim Coleman (tim@timcoleman.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) Dave Bettin, 2002
// Copyright (C) Tim Coleman, 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.
//
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace System.Web.Services.Discovery {
[XmlRoot ("discovery", Namespace = "http://schemas.xmlsoap.org/disco/")]
public sealed class DiscoveryDocument {
#region Fields
public const string Namespace = "http://schemas.xmlsoap.org/disco/";
[XmlElement(typeof(ContractReference), Namespace="http://schemas.xmlsoap.org/disco/scl/")]
[XmlElement(typeof(DiscoveryDocumentReference))]
[XmlElement(typeof(SchemaReference))]
internal ArrayList references = new ArrayList();
[XmlElement(typeof(SoapBinding), ElementName="soap", Namespace="http://schemas/xmlsoap.org/disco/schema/soap/")]
internal ArrayList additionalInfo = new ArrayList();
#endregion // Fields
#region Constructors
public DiscoveryDocument ()
{
}
#endregion // Constructors
#region Properties
[XmlIgnore]
public IList References {
get { return references; }
}
[XmlIgnore]
internal IList AdditionalInfo {
get { return additionalInfo; }
}
#endregion // Properties
#region Methods
public static bool CanRead (XmlReader xmlReader)
{
xmlReader.MoveToContent ();
return xmlReader.NodeType == XmlNodeType.Element &&
xmlReader.LocalName == "discovery" &&
xmlReader.NamespaceURI == Namespace;
}
public static DiscoveryDocument Read (Stream stream)
{
return Read (new XmlTextReader (stream));
}
public static DiscoveryDocument Read (TextReader textReader)
{
return Read (new XmlTextReader (textReader));
}
public static DiscoveryDocument Read (XmlReader xmlReader)
{
DiscoveryDocumentSerializer ser = new DiscoveryDocumentSerializer();
return (DiscoveryDocument) ser.Deserialize (xmlReader);
}
public void Write (Stream stream)
{
DiscoveryDocumentSerializer ser = new DiscoveryDocumentSerializer();
ser.Serialize (stream, this, GetNamespaceList());
}
public void Write (TextWriter textWriter)
{
DiscoveryDocumentSerializer ser = new DiscoveryDocumentSerializer();
ser.Serialize (textWriter, this, GetNamespaceList());
}
public void Write (XmlWriter xmlWriter)
{
DiscoveryDocumentSerializer ser = new DiscoveryDocumentSerializer();
ser.Serialize (xmlWriter, this, GetNamespaceList());
}
XmlSerializerNamespaces GetNamespaceList ()
{
XmlSerializerNamespaces ns = new XmlSerializerNamespaces ();
ns.Add ("scl", ContractReference.Namespace);
return ns;
}
#endregion // Methods
}
internal class DiscoveryDocumentSerializer : XmlSerializer
{
protected override void Serialize (object o, XmlSerializationWriter writer)
{
DiscoveryDocumentWriter xsWriter = writer as DiscoveryDocumentWriter;
xsWriter.WriteRoot_DiscoveryDocument (o);
}
protected override object Deserialize (XmlSerializationReader reader)
{
DiscoveryDocumentReader xsReader = reader as DiscoveryDocumentReader;
return xsReader.ReadRoot_DiscoveryDocument ();
}
protected override XmlSerializationWriter CreateWriter ()
{
return new DiscoveryDocumentWriter ();
}
protected override XmlSerializationReader CreateReader ()
{
return new DiscoveryDocumentReader ();
}
}
}

View File

@@ -0,0 +1,69 @@
//
// System.Web.Services.Protocols.DiscoveryDocumentLinksPattern.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
namespace System.Web.Services.Discovery {
public class DiscoveryDocumentLinksPattern : DiscoverySearchPattern {
#region Fields
private string pattern = "*.disco";
#endregion // Fields
#region Constructors
public DiscoveryDocumentLinksPattern ()
{
}
#endregion // Constructors
#region Properties
public override string Pattern {
get { return pattern; }
}
#endregion // Properties
#region Methods
public override DiscoveryReference GetDiscoveryReference (string filename)
{
DiscoveryDocumentReference refe = new DiscoveryDocumentReference ();
refe.Url = filename;
refe.Ref = filename;
return refe;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,151 @@
//
// System.Web.Services.Discovery.DiscoveryDocumentReference.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Tim Coleman (tim@timcoleman.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) Dave Bettin, 2002
// Copyright (C) Tim Coleman, 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.
//
using System.IO;
using System.Web.Services.Description;
using System.Xml.Serialization;
namespace System.Web.Services.Discovery {
[XmlRootAttribute("discoveryRef", Namespace="http://schemas.xmlsoap.org/disco/", IsNullable=true)]
public sealed class DiscoveryDocumentReference : DiscoveryReference {
#region Fields
private DiscoveryDocument document;
private string defaultFilename;
private string href;
#endregion // Fields
#region Constructors
public DiscoveryDocumentReference ()
{
href = String.Empty;
}
public DiscoveryDocumentReference (string href)
{
this.href = href;
}
#endregion // Constructors
#region Properties
[XmlIgnore]
public DiscoveryDocument Document {
get {
if (ClientProtocol == null)
throw new InvalidOperationException ("The ClientProtocol property is a null reference");
DiscoveryDocument doc = ClientProtocol.Documents [Url] as DiscoveryDocument;
if (doc == null)
throw new Exception ("The Documents property of ClientProtocol does not contain a discovery document with the url " + Url);
return doc;
}
}
[XmlIgnore]
public override string DefaultFilename {
get { return FilenameFromUrl (Url) + ".disco"; }
}
[XmlAttribute("ref")]
public string Ref {
get { return href; }
set { href = value; }
}
[XmlIgnore]
public override string Url {
get { return href; }
set { href = value; }
}
#endregion // Properties
#region Methods
public override object ReadDocument (Stream stream)
{
return DiscoveryDocument.Read (stream);
}
protected internal override void Resolve (string contentType, Stream stream)
{
DiscoveryDocument doc = DiscoveryDocument.Read (stream);
ClientProtocol.Documents.Add (Url, doc);
if (!ClientProtocol.References.Contains (Url))
ClientProtocol.References.Add (this);
foreach (DiscoveryReference re in doc.References)
{
re.ClientProtocol = ClientProtocol;
ClientProtocol.References.Add (re.Url, re);
}
}
public void ResolveAll ()
{
if (ClientProtocol.Documents.Contains (Url)) // Already resolved
return;
Resolve ();
DiscoveryDocument doc = document;
foreach (DiscoveryReference re in doc.References)
{
try
{
if (re is DiscoveryDocumentReference)
((DiscoveryDocumentReference)re).ResolveAll ();
else
re.Resolve ();
}
catch (Exception ex)
{
ReportError (re.Url, ex);
}
}
}
public override void WriteDocument (object document, Stream stream)
{
((DiscoveryDocument)document).Write (stream);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,69 @@
//
// System.Web.Services.Discovery.DiscoveryDocumentSearchPattern.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
namespace System.Web.Services.Discovery {
public sealed class DiscoveryDocumentSearchPattern : DiscoverySearchPattern {
#region Fields
private string pattern = "*.vsdisco";
#endregion // Fields
#region Constructors
public DiscoveryDocumentSearchPattern ()
{
}
#endregion // Constructors
#region Properties
public override string Pattern {
get { return pattern; }
}
#endregion // Properties
#region Methods
public override DiscoveryReference GetDiscoveryReference (string filename)
{
DiscoveryDocumentReference refe = new DiscoveryDocumentReference ();
refe.Url = filename;
refe.Ref = filename;
return refe;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,86 @@
//
// System.Web.Services.Protocols.DiscoveryExceptionDictionary.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.Collections;
namespace System.Web.Services.Discovery
{
public sealed class DiscoveryExceptionDictionary : DictionaryBase
{
#region Constructors
public DiscoveryExceptionDictionary ()
{
}
#endregion // Constructors
#region Properties
public Exception this[string url] {
get { return (Exception) InnerHashtable [url]; }
set {
if (url == null)
throw new ArgumentNullException ();
InnerHashtable [url] = value;
}
}
public ICollection Keys {
get { return InnerHashtable.Keys; }
}
public ICollection Values {
get { return InnerHashtable.Values; }
}
#endregion // Properties
#region Methods
public void Add (string url, Exception value)
{
InnerHashtable.Add (url, value);
}
public bool Contains (string url)
{
return InnerHashtable.Contains (url);
}
public void Remove (string url)
{
InnerHashtable.Remove (url);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,148 @@
//
// System.Web.Services.Discovery.DiscoveryReference.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.IO;
using System.Xml.Serialization;
namespace System.Web.Services.Discovery {
public abstract class DiscoveryReference {
#region Fields
private string defaultFilename;
private DiscoveryClientProtocol clientProtocol;
#endregion // Fields
#region Constructors
protected DiscoveryReference ()
{
}
#endregion // Constructors
#region Properties
[XmlIgnore]
public DiscoveryClientProtocol ClientProtocol {
get { return clientProtocol; }
set { clientProtocol = value; }
}
[XmlIgnore]
public virtual string DefaultFilename {
get { return FilenameFromUrl (Url); }
}
[XmlIgnore]
public abstract string Url {
get;
set;
}
internal Uri BaseUri
{
get
{
int i = Url.IndexOf ("://");
if (i == -1 || !Uri.CheckSchemeName (Url.Substring (0,i)))
return new Uri ("file://" + Url);
else
return new Uri (Url);
}
}
#endregion // Properties
#region Methods
public static string FilenameFromUrl (string url)
{
if (url.ToLower().EndsWith ("/wsdl"))
url = url.Substring (0,url.Length-5);
else if (url.ToLower().EndsWith ("/soap"))
url = url.Substring (0,url.Length-5);
else if (url.ToLower().EndsWith ("/wsdl.jsp"))
url = url.Substring (0,url.Length-9);
else if (url.ToLower().EndsWith ("/soap.wsdl"))
url = url.Substring (0,url.Length-10);
int i = url.LastIndexOf ("/");
if (i != -1) url = url.Substring (i+1);
i = url.IndexOfAny (new char[] {'.','?','\\'});
if (i != -1) url = url.Substring (0,i);
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
for (int n=0; n<url.Length; n++)
if (Char.IsLetterOrDigit (url[n]) || url[n] == '_') sb.Append (url[n]);
return sb.ToString ();
}
public abstract object ReadDocument (Stream stream);
public void Resolve ()
{
if (clientProtocol == null)
throw new InvalidOperationException ("The ClientProtocol property is a null reference.");
if (clientProtocol.Documents.Contains (Url)) // Already resolved
return;
try
{
string contentType = null;
string url = Url;
Stream stream = clientProtocol.Download (ref url, ref contentType);
Resolve (contentType, stream);
}
catch (Exception ex)
{
ReportError (Url, ex);
}
}
protected internal abstract void Resolve (string contentType, Stream stream);
public abstract void WriteDocument (object document, Stream stream);
internal void ReportError (string url, Exception ex)
{
if (ex is DiscoveryException) throw ex;
else throw new DiscoveryException (url, ex);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,83 @@
//
// System.Web.Services.Protocols.DiscoveryReferenceCollection.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Dave Bettin, 2002
// Copyright (C) Tim Coleman, 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.
//
using System.Collections;
namespace System.Web.Services.Discovery {
public sealed class DiscoveryReferenceCollection : CollectionBase {
#region Constructors
public DiscoveryReferenceCollection ()
: base ()
{
}
#endregion // Constructors
#region Properties
public DiscoveryReference this [int i] {
get {
if (i < 0 || i >= Count)
throw new ArgumentOutOfRangeException ();
return (DiscoveryReference) InnerList [i];
}
set {
if (i < 0 || i >= Count)
throw new ArgumentOutOfRangeException ();
InnerList [i] = value;
}
}
#endregion // Properties
#region Methods
public int Add (DiscoveryReference value)
{
return InnerList.Add (value);
}
public bool Contains (DiscoveryReference value)
{
return InnerList.Contains (value);
}
public void Remove (DiscoveryReference value)
{
InnerList.Remove (value);
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,110 @@
//
// System.Web.Services.Discovery.DiscoveryRequestHandler.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.Web;
using System.IO;
using System.Web.Services.Discovery;
namespace System.Web.Services.Discovery {
public sealed class DiscoveryRequestHandler : IHttpHandler {
#region Constructors
public DiscoveryRequestHandler ()
{
}
#endregion // Constructors
#region Properties
public bool IsReusable {
get { return true; }
}
#endregion // Properties
#region Methods
public void ProcessRequest (HttpContext context)
{
string path = context.Request.PhysicalPath;
FileStream fs = new FileStream (path, FileMode.Open, FileAccess.Read);
DynamicDiscoveryDocument ddoc = DynamicDiscoveryDocument.Load (fs);
fs.Close ();
string url = context.Request.Url.ToString();
int i = url.LastIndexOf ('/');
if (i != -1) url = url.Substring (0,i+1);
DiscoveryDocument doc = new DiscoveryDocument ();
GetFiles (url, "", Path.GetDirectoryName(path), doc, ddoc);
context.Response.ContentType = "text/xml; charset=utf-8";
doc.Write (context.Response.OutputStream);
}
void GetFiles (string baseUrl, string relPath, string path, DiscoveryDocument doc, DynamicDiscoveryDocument ddoc)
{
string url = baseUrl + relPath;
if (!url.EndsWith ("/")) url += "/";
string[] files = Directory.GetFiles (path);
foreach (string file in files)
{
string ext = Path.GetExtension (file).ToLower();
if (ext == ".asmx")
{
ContractReference cref = new ContractReference ();
cref.DocRef = url + Path.GetFileName (file);
cref.Ref = cref.DocRef + "?wsdl";
doc.References.Add (cref);
}
else if (ext == ".disco")
{
DiscoveryDocumentReference dref = new DiscoveryDocumentReference ();
dref.Ref = url + Path.GetFileName (file);
doc.References.Add (dref);
}
}
string[] dirs = Directory.GetDirectories (path);
foreach (string dir in dirs)
{
string rel = Path.Combine (relPath, Path.GetFileName(dir));
if (!ddoc.IsExcluded (rel))
GetFiles (baseUrl, rel, Path.Combine (path, dir), doc, ddoc);
}
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,54 @@
//
// System.Web.Services.Discovery.DiscoverySearchPattern.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
//
// 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.
//
namespace System.Web.Services.Discovery {
public abstract class DiscoverySearchPattern {
#region Constructors
protected DiscoverySearchPattern () {}
#endregion // Constructors
#region Properties
public abstract string Pattern {
get;
}
#endregion // Properties
#region Methods
public abstract DiscoveryReference GetDiscoveryReference (string filename);
#endregion // Methods
}
}

View File

@@ -0,0 +1,92 @@
//
// System.Web.Services.Discovery.DynamicDiscoveryDocument.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 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.
//
using System.IO;
using System.Xml.Serialization;
namespace System.Web.Services.Discovery {
[XmlRootAttribute("dynamicDiscovery", Namespace="urn:schemas-dynamicdiscovery:disco.2000-03-17", IsNullable=true)]
public sealed class DynamicDiscoveryDocument {
#region Fields
public const string Namespace = "urn:schemas-dynamicdiscovery:disco.2000-03-17";
ExcludePathInfo[] excludes;
#endregion // Fields
#region Constructors
public DynamicDiscoveryDocument ()
{
}
#endregion // Constructors
#region Properties
[XmlElement("exclude", typeof(ExcludePathInfo))]
public ExcludePathInfo[] ExcludePaths {
get { return excludes; }
set { excludes = value; }
}
#endregion // Properties
#region Methods
public static DynamicDiscoveryDocument Load (Stream stream)
{
XmlSerializer ser = new XmlSerializer (typeof(DynamicDiscoveryDocument));
return (DynamicDiscoveryDocument) ser.Deserialize (stream);
}
public void Write (Stream stream)
{
XmlSerializer ser = new XmlSerializer (typeof(DynamicDiscoveryDocument));
ser.Serialize (stream, this);
}
internal bool IsExcluded (string path)
{
if (excludes == null) return false;
foreach (ExcludePathInfo ex in excludes)
if (ex.Path == path) return true;
return false;
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,65 @@
//
// System.Web.Services.Discovery.ExcludePathInfo.cs
//
// Author:
// Dave Bettin (javabettin@yahoo.com)
//
// 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.
//
using System.Xml.Serialization;
namespace System.Web.Services.Discovery {
public sealed class ExcludePathInfo {
#region Fields
private string path;
#endregion // Fields
#region Constructors
public ExcludePathInfo ()
{
}
public ExcludePathInfo (string path)
{
this.path = path;
}
#endregion // Constructors
#region Properties
[XmlAttribute("path")]
public string Path {
get { return path; }
set { path = value; }
}
#endregion // Properties
}
}

Some files were not shown because too many files have changed in this diff Show More