2 // System.Web.Services.Protocols.DiscoveryDocument.cs
5 // Dave Bettin (javabettin@yahoo.com)
6 // Tim Coleman (tim@timcoleman.com)
7 // Lluis Sanchez Gual (lluis@ximian.com)
9 // Copyright (C) Dave Bettin, 2002
10 // Copyright (C) Tim Coleman, 2002
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System
.Collections
;
37 using System
.Xml
.Serialization
;
39 namespace System
.Web
.Services
.Discovery
{
40 [XmlRoot ("discovery", Namespace
= "http://schemas.xmlsoap.org/disco/")]
41 public sealed class DiscoveryDocument
{
45 public const string Namespace
= "http://schemas.xmlsoap.org/disco/";
47 [XmlElement(typeof(ContractReference
), Namespace
="http://schemas.xmlsoap.org/disco/scl/")]
48 [XmlElement(typeof(DiscoveryDocumentReference
))]
49 [XmlElement(typeof(SchemaReference
))]
50 internal ArrayList references
= new ArrayList();
52 [XmlElement(typeof(SoapBinding
), ElementName
="soap", Namespace
="http://schemas/xmlsoap.org/disco/schema/soap/")]
53 internal ArrayList additionalInfo
= new ArrayList();
59 public DiscoveryDocument ()
63 #endregion // Constructors
68 public IList References
{
69 get { return references; }
73 internal IList AdditionalInfo
{
74 get { return additionalInfo; }
77 #endregion // Properties
81 public static bool CanRead (XmlReader xmlReader
)
83 xmlReader
.MoveToContent ();
84 return xmlReader
.NodeType
== XmlNodeType
.Element
&&
85 xmlReader
.LocalName
== "discovery" &&
86 xmlReader
.NamespaceURI
== Namespace
;
89 public static DiscoveryDocument
Read (Stream stream
)
91 return Read (new XmlTextReader (stream
));
94 public static DiscoveryDocument
Read (TextReader textReader
)
96 return Read (new XmlTextReader (textReader
));
99 public static DiscoveryDocument
Read (XmlReader xmlReader
)
101 DiscoveryDocumentSerializer ser
= new DiscoveryDocumentSerializer();
102 return (DiscoveryDocument
) ser
.Deserialize (xmlReader
);
105 public void Write (Stream stream
)
107 DiscoveryDocumentSerializer ser
= new DiscoveryDocumentSerializer();
108 ser
.Serialize (stream
, this, GetNamespaceList());
111 public void Write (TextWriter textWriter
)
113 DiscoveryDocumentSerializer ser
= new DiscoveryDocumentSerializer();
114 ser
.Serialize (textWriter
, this, GetNamespaceList());
117 public void Write (XmlWriter xmlWriter
)
119 DiscoveryDocumentSerializer ser
= new DiscoveryDocumentSerializer();
120 ser
.Serialize (xmlWriter
, this, GetNamespaceList());
123 XmlSerializerNamespaces
GetNamespaceList ()
125 XmlSerializerNamespaces ns
= new XmlSerializerNamespaces ();
126 ns
.Add ("scl", ContractReference
.Namespace
);
130 #endregion // Methods
133 internal class DiscoveryDocumentSerializer
: XmlSerializer
135 protected override void Serialize (object o
, XmlSerializationWriter writer
)
137 DiscoveryDocumentWriter xsWriter
= writer
as DiscoveryDocumentWriter
;
138 xsWriter
.WriteRoot_DiscoveryDocument (o
);
141 protected override object Deserialize (XmlSerializationReader reader
)
143 DiscoveryDocumentReader xsReader
= reader
as DiscoveryDocumentReader
;
144 return xsReader
.ReadRoot_DiscoveryDocument ();
147 protected override XmlSerializationWriter
CreateWriter ()
149 return new DiscoveryDocumentWriter ();
152 protected override XmlSerializationReader
CreateReader ()
154 return new DiscoveryDocumentReader ();