2006-11-14 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 14 Nov 2006 07:33:56 +0000 (07:33 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 14 Nov 2006 07:33:56 +0000 (07:33 -0000)
* wsdl-1.1.xsd : imported from the spec site (schemas.xmlsoap.org)
  to be used for ServiceDescription.Schema.
* ServiceDescription.cs : added Schema property and validating Read()
  overloads.

* ServiceDescriptionTest.cs : added test for invalid Read() inputs.

* Makefile : added *.wsdl to the build.
  Added wsdl and genxs to EXTRA_DISTFILES.

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

mcs/class/System.Web.Services/ChangeLog
mcs/class/System.Web.Services/Makefile
mcs/class/System.Web.Services/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/System.Web.Services.Description/ServiceDescription.cs
mcs/class/System.Web.Services/System.Web.Services.Description/wsdl-1.1.xsd [new file with mode: 0644]
mcs/class/System.Web.Services/Test/System.Web.Services.Description/ChangeLog
mcs/class/System.Web.Services/Test/System.Web.Services.Description/ServiceDescriptionTest.cs

index 1ec637c22c0adaa9e9f5d1f5c903a114b2ad39e4..4f97fce6dc3670d949b1aa226a1bdd8b2a48d112 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : added *.wsdl to the build.
+         Added wsdl and genxs to EXTRA_DISTFILES.
+
 2006-09-06  Vladimir Krasnov <vladimirk@mainsoft.com>
 
        * System.Web.Services20.vmwcsproj: added
index 1adae6c9eb91fc1554c84a66af7b3ae5a3e6d0b6..7e13d882946854441bc10838628756ffd890822c 100644 (file)
@@ -12,11 +12,16 @@ LIB_MCS_FLAGS = \
        -r:System.Web.dll
 
 ifeq (net_2_0, $(PROFILE))
-LIB_MCS_FLAGS += -r:System.Configuration.dll
+LIB_MCS_FLAGS += \
+       -r:System.Configuration.dll \
+       -resource:System.Web.Services.Description/wsdl-1.1.xsd,wsdl-1.1.xsd
 endif
 
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:618
 
-EXTRA_DISTFILES = Test/System.Web.Services.Description/test.wsdl
+EXTRA_DISTFILES = \
+       System.Web.Services.Description/wsdl-1.1.xsd    \
+       System.Web.Services.Description/wsdl.genxs      \
+       Test/System.Web.Services.Description/test.wsdl
 
 include ../../build/library.make
index 35ec8db8e4dfc5aa64b6f0abd8bcf712d129c20a..d2aebd28d8fd4da154096508c3236c34c90bb794 100644 (file)
@@ -1,3 +1,10 @@
+2006-11-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * wsdl-1.1.xsd : imported from the spec site (schemas.xmlsoap.org)
+         to be used for ServiceDescription.Schema.
+       * ServiceDescription.cs : added Schema property and validating Read() 
+         overloads.
+
 2006-11-07  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ServiceDescriptionSerializerBase2.cs :
index e7f58bf3865497b4bc552cce4ab7fe4ca97ba067..f54ca76a6cc114772c129c920dfa504d414eb411 100644 (file)
@@ -31,6 +31,7 @@
 \r
 using System.IO;\r
 using System.Collections;\r
+using System.Collections.Specialized;\r
 using System.Reflection;\r
 using System.Web.Services;\r
 using System.Web.Services.Configuration;\r
@@ -71,6 +72,11 @@ namespace System.Web.Services.Description
                string targetNamespace;\r
                Types types;\r
                static ServiceDescriptionSerializer serializer;\r
+#if NET_2_0\r
+               StringCollection validationWarnings;\r
+\r
+               static XmlSchema schema;\r
+#endif\r
 \r
                #endregion // Fields\r
 \r
@@ -102,6 +108,17 @@ namespace System.Web.Services.Description
 \r
                #region Properties\r
 \r
+#if NET_2_0\r
+               public static XmlSchema Schema {\r
+                       get {\r
+                               if (schema == null) {\r
+                                       schema = XmlSchema.Read (typeof (ServiceDescription).Assembly.GetManifestResourceStream ("wsdl-1.1.xsd"), null);\r
+                               }\r
+                               return schema;\r
+                       }\r
+               }\r
+#endif\r
+\r
                [XmlElement ("import")]\r
                public ImportCollection Imports {\r
                        get { return imports; }\r
@@ -174,6 +191,12 @@ namespace System.Web.Services.Description
                        set { targetNamespace = value; }\r
                }\r
 \r
+#if NET_2_0\r
+               public StringCollection ValidationWarnings {\r
+                       get { return validationWarnings; }\r
+               }\r
+#endif\r
+\r
                #endregion // Properties\r
 \r
                #region Methods\r
@@ -185,6 +208,53 @@ namespace System.Web.Services.Description
                                reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/";\r
                }\r
 \r
+#if NET_2_0\r
+               public static ServiceDescription Read (string fileName, bool validate)\r
+               {\r
+                       if (validate)\r
+                               using (XmlReader reader = XmlReader.Create (fileName)) {\r
+                                       return Read (reader, true);\r
+                               }\r
+                       else\r
+                               return Read (fileName);\r
+               }\r
+\r
+               public static ServiceDescription Read (Stream stream, bool validate)\r
+               {\r
+                       if (validate)\r
+                               return Read (XmlReader.Create (stream), true);\r
+                       else\r
+                               return Read (stream);\r
+               }\r
+\r
+               public static ServiceDescription Read (TextReader reader, bool validate)\r
+               {\r
+                       if (validate)\r
+                               return Read (XmlReader.Create (reader), true);\r
+                       else\r
+                               return Read (reader);\r
+               }\r
+\r
+               public static ServiceDescription Read (XmlReader reader, bool validate)\r
+               {\r
+                       if (validate) {\r
+                               StringCollection sc = new StringCollection ();\r
+                               XmlReaderSettings s = new XmlReaderSettings ();\r
+                               s.ValidationType = ValidationType.Schema;\r
+                               s.Schemas.Add (Schema);\r
+                               s.ValidationEventHandler += delegate (object o, ValidationEventArgs e) {\r
+                                       sc.Add (e.Message);\r
+                               };\r
+\r
+                               ServiceDescription ret = Read (XmlReader.Create (reader, s));\r
+                               ret.validationWarnings = sc;\r
+                               return ret;\r
+                       }\r
+                       else\r
+                               return Read (reader);\r
+               }\r
+#endif\r
+\r
                public static ServiceDescription Read (Stream stream)\r
                {\r
                        return (ServiceDescription) serializer.Deserialize (stream);\r
diff --git a/mcs/class/System.Web.Services/System.Web.Services.Description/wsdl-1.1.xsd b/mcs/class/System.Web.Services/System.Web.Services.Description/wsdl-1.1.xsd
new file mode 100644 (file)
index 0000000..14b5bef
--- /dev/null
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="UTF-8" ?> 
+<!-- 
+Copyright 2001 - 2005, International Business Machines Corporation and Microsoft Corporation
+All Rights Reserved
+
+License for WSDL Schema Files
+
+The Authors grant permission to copy and distribute the WSDL Schema 
+Files in any medium without fee or royalty as long as this notice and 
+license are distributed with them.  The originals of these files can 
+be located at:
+
+http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd
+
+THESE SCHEMA FILES ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS 
+OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THESE FILES, INCLUDING, BUT NOT 
+LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 
+NON-INFRINGEMENT OR TITLE.  THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, 
+INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR 
+RELATING TO ANY USE OR DISTRIBUTION OF THESE FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, 
+including advertising or publicity pertaining to these files or any program 
+or service that uses these files, written prior permission.  Title to copyright 
+in these files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+
+--> 
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+           targetNamespace="http://schemas.xmlsoap.org/wsdl/"
+           elementFormDefault="qualified" >
+   
+  <xs:complexType mixed="true" name="tDocumentation" >
+    <xs:sequence>
+      <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="tDocumented" >
+    <xs:annotation>
+      <xs:documentation>
+      This type is extended by  component types to allow them to be documented
+      </xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="documentation" type="wsdl:tDocumentation" minOccurs="0" />
+    </xs:sequence>
+  </xs:complexType>
+        
+  <xs:complexType name="tExtensibleAttributesDocumented" abstract="true" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tDocumented" >
+        <xs:annotation>
+          <xs:documentation>
+          This type is extended by component types to allow attributes from other namespaces to be added.
+          </xs:documentation>
+        </xs:annotation>
+        <xs:anyAttribute namespace="##other" processContents="lax" />    
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:complexType name="tExtensibleDocumented" abstract="true" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tDocumented" >
+        <xs:annotation>
+          <xs:documentation>
+          This type is extended by component types to allow elements from other namespaces to be added.
+          </xs:documentation>
+        </xs:annotation>
+        <xs:sequence>
+          <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:element name="definitions" type="wsdl:tDefinitions" >
+    <xs:key name="message" >
+      <xs:selector xpath="wsdl:message" />
+      <xs:field xpath="@name" />
+    </xs:key>
+    <xs:key name="portType" >
+      <xs:selector xpath="wsdl:portType" />
+      <xs:field xpath="@name" />
+    </xs:key>
+    <xs:key name="binding" >
+      <xs:selector xpath="wsdl:binding" />
+      <xs:field xpath="@name" />
+    </xs:key>
+    <xs:key name="service" >
+      <xs:selector xpath="wsdl:service" />
+      <xs:field xpath="@name" />
+    </xs:key>
+    <xs:key name="import" >
+      <xs:selector xpath="wsdl:import" />
+      <xs:field xpath="@namespace" />
+    </xs:key>
+  </xs:element>
+
+  <xs:group name="anyTopLevelOptionalElement" >
+    <xs:annotation>
+      <xs:documentation>
+      Any top level optional element allowed to appear more then once - any child of definitions element except wsdl:types. Any extensibility element is allowed in any place.
+      </xs:documentation>
+    </xs:annotation>
+    <xs:choice>
+      <xs:element name="import" type="wsdl:tImport" />
+      <xs:element name="types" type="wsdl:tTypes" />                     
+      <xs:element name="message"  type="wsdl:tMessage" >
+        <xs:unique name="part" >
+          <xs:selector xpath="wsdl:part" />
+          <xs:field xpath="@name" />
+        </xs:unique>
+      </xs:element>
+      <xs:element name="portType" type="wsdl:tPortType" />
+      <xs:element name="binding"  type="wsdl:tBinding" />
+      <xs:element name="service"  type="wsdl:tService" >
+        <xs:unique name="port" >
+          <xs:selector xpath="wsdl:port" />
+          <xs:field xpath="@name" />
+        </xs:unique>
+         </xs:element>
+    </xs:choice>
+  </xs:group>
+
+  <xs:complexType name="tDefinitions" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:sequence>
+          <xs:group ref="wsdl:anyTopLevelOptionalElement"  minOccurs="0"   maxOccurs="unbounded" />
+        </xs:sequence>
+        <xs:attribute name="targetNamespace" type="xs:anyURI" use="optional" />
+        <xs:attribute name="name" type="xs:NCName" use="optional" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+   
+  <xs:complexType name="tImport" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleAttributesDocumented" >
+        <xs:attribute name="namespace" type="xs:anyURI" use="required" />
+        <xs:attribute name="location" type="xs:anyURI" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+   
+  <xs:complexType name="tTypes" >
+    <xs:complexContent>   
+      <xs:extension base="wsdl:tExtensibleDocumented" />
+    </xs:complexContent>   
+  </xs:complexType>
+     
+  <xs:complexType name="tMessage" >
+    <xs:complexContent>   
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:sequence>
+          <xs:element name="part" type="wsdl:tPart" minOccurs="0" maxOccurs="unbounded" />
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+      </xs:extension>
+    </xs:complexContent>   
+  </xs:complexType>
+
+  <xs:complexType name="tPart" >
+    <xs:complexContent>   
+      <xs:extension base="wsdl:tExtensibleAttributesDocumented" >
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+        <xs:attribute name="element" type="xs:QName" use="optional" />
+        <xs:attribute name="type" type="xs:QName" use="optional" />    
+      </xs:extension>
+    </xs:complexContent>   
+  </xs:complexType>
+
+  <xs:complexType name="tPortType" >
+    <xs:complexContent>   
+      <xs:extension base="wsdl:tExtensibleAttributesDocumented" >
+        <xs:sequence>
+          <xs:element name="operation" type="wsdl:tOperation" minOccurs="0" maxOccurs="unbounded" />
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+      </xs:extension>
+    </xs:complexContent>   
+  </xs:complexType>
+   
+  <xs:complexType name="tOperation" >
+    <xs:complexContent>   
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+           <xs:sequence>
+          <xs:choice>
+            <xs:group ref="wsdl:request-response-or-one-way-operation" />
+            <xs:group ref="wsdl:solicit-response-or-notification-operation" />
+          </xs:choice>
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+        <xs:attribute name="parameterOrder" type="xs:NMTOKENS" use="optional" />
+      </xs:extension>
+    </xs:complexContent>   
+  </xs:complexType>
+    
+  <xs:group name="request-response-or-one-way-operation" >
+    <xs:sequence>
+      <xs:element name="input" type="wsdl:tParam" />
+         <xs:sequence minOccurs='0' >
+           <xs:element name="output" type="wsdl:tParam" />
+               <xs:element name="fault" type="wsdl:tFault" minOccurs="0" maxOccurs="unbounded" />
+      </xs:sequence>
+    </xs:sequence>
+  </xs:group>
+
+  <xs:group name="solicit-response-or-notification-operation" >
+    <xs:sequence>
+      <xs:element name="output" type="wsdl:tParam" />
+         <xs:sequence minOccurs='0' >
+           <xs:element name="input" type="wsdl:tParam" />
+               <xs:element name="fault" type="wsdl:tFault" minOccurs="0" maxOccurs="unbounded" />
+         </xs:sequence>
+    </xs:sequence>
+  </xs:group>
+        
+  <xs:complexType name="tParam" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleAttributesDocumented" >
+        <xs:attribute name="name" type="xs:NCName" use="optional" />
+        <xs:attribute name="message" type="xs:QName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:complexType name="tFault" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleAttributesDocumented" >
+        <xs:attribute name="name" type="xs:NCName"  use="required" />
+        <xs:attribute name="message" type="xs:QName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+     
+  <xs:complexType name="tBinding" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:sequence>
+          <xs:element name="operation" type="wsdl:tBindingOperation" minOccurs="0" maxOccurs="unbounded" />
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+        <xs:attribute name="type" type="xs:QName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+    
+  <xs:complexType name="tBindingOperationMessage" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:attribute name="name" type="xs:NCName" use="optional" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  
+  <xs:complexType name="tBindingOperationFault" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:complexType name="tBindingOperation" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:sequence>
+          <xs:element name="input" type="wsdl:tBindingOperationMessage" minOccurs="0" />
+          <xs:element name="output" type="wsdl:tBindingOperationMessage" minOccurs="0" />
+          <xs:element name="fault" type="wsdl:tBindingOperationFault" minOccurs="0" maxOccurs="unbounded" />
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+     
+  <xs:complexType name="tService" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:sequence>
+          <xs:element name="port" type="wsdl:tPort" minOccurs="0" maxOccurs="unbounded" />
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+     
+  <xs:complexType name="tPort" >
+    <xs:complexContent>
+      <xs:extension base="wsdl:tExtensibleDocumented" >
+        <xs:attribute name="name" type="xs:NCName" use="required" />
+        <xs:attribute name="binding" type="xs:QName" use="required" />
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:attribute name="arrayType" type="xs:string" />
+  <xs:attribute name="required" type="xs:boolean" />
+  <xs:complexType name="tExtensibilityElement" abstract="true" >
+    <xs:attribute ref="wsdl:required" use="optional" />
+  </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
index 9e956225de55d5f9d065ad4e3895f84d4c8b7d69..6a21fddce78aa00013c27ddc4da60a5dbb04cde9 100644 (file)
@@ -1,3 +1,7 @@
+2006-11-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDescriptionTest.cs : added test for invalid Read() inputs.
+
 2006-09-07  Ankit Jain  <jankit@novell.com>
 
        * ServiceDescriptionTest.cs (Ctor): New.
index 7061d0e35570a552ee5f40a07d1757e9ea5843d4..dcb390c3f36d3a11dd91ecd63533ed9da7c956ed 100644 (file)
@@ -161,6 +161,18 @@ namespace MonoTests.System.Web.Services.Description
                        Assert.AreEqual (val, di.ExtensibleAttributes [0].Value);
                }
 
+               [Test]
+               public void ReadInvalid ()
+               {
+                       ServiceDescription sd = ServiceDescription.Read (XmlReader.Create (new StringReader ("<definitions xmlns='http://schemas.xmlsoap.org/wsdl/'><hoge/></definitions>")));
+               }
+
+               [Test]
+               public void ValidatingRead ()
+               {
+                       ServiceDescription sd = ServiceDescription.Read (XmlReader.Create (new StringReader ("<definitions xmlns='http://schemas.xmlsoap.org/wsdl/'><hoge/></definitions>")), true);
+                       Assert.IsTrue (sd.ValidationWarnings.Count > 0);
+               }
 #endif
 
     }