2 // System.Web.Services.Description.BasicProfileChecker.cs
5 // Lluis Sanchez (lluis@novell.com)
7 // Copyright (C) Novell, Inc., 2004
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Xml.Schema;
35 namespace System.Web.Services.Description
37 internal class BasicProfileChecker: ConformanceChecker
39 public static BasicProfileChecker Instance = new BasicProfileChecker ();
41 public override WsiClaims Claims {
42 get { return WsiClaims.BP10; }
45 public override void Check (ConformanceCheckContext ctx, Import value)
47 if (value.Location == "" || value.Location == null) {
48 ctx.ReportRuleViolation (value, BasicProfileRules.R2007);
52 object doc = ctx.GetDocument (value.Location);
53 if (doc == null) ctx.ReportError (value, "Document '" + value.Location + "' not found");
56 ctx.ReportRuleViolation (value, BasicProfileRules.R2002);
58 ServiceDescription imported = doc as ServiceDescription;
59 if (imported == null) {
60 ctx.ReportRuleViolation (value, BasicProfileRules.R2001);
66 if (imported.TargetNamespace != value.Namespace)
67 ctx.ReportRuleViolation (value, BasicProfileRules.R2005);
70 public override void Check (ConformanceCheckContext ctx, ServiceDescription value)
75 public override void Check (ConformanceCheckContext ctx, ServiceDescriptionFormatExtension value)
78 ctx.ReportRuleViolation (value, BasicProfileRules.R2026);
81 public override void Check (ConformanceCheckContext ctx, XmlSchemaObject value)
83 if (value is XmlSchemaImport) {
84 XmlSchemaImport import = (XmlSchemaImport) value;
85 XmlSchema doc = ctx.GetDocument (import.SchemaLocation) as XmlSchema;
86 if (doc == null) ctx.ReportError (value, "Schema '" + import.SchemaLocation + "' not found");
88 // TODO: rule R2004, R2010, R2011
94 internal class BasicProfileRules
96 public static readonly ConformanceRule R2001 = new ConformanceRule (
98 "A DESCRIPTION MUST only use the WSDL \"import\" statement to import another WSDL description",
101 public static readonly ConformanceRule R2002 = new ConformanceRule (
103 "To import XML Schema Definitions, a DESCRIPTION MUST use the XML Schema \"import\" statement",
106 public static readonly ConformanceRule R2007 = new ConformanceRule (
108 "A DESCRIPTION MUST specify a non-empty location attribute on the wsdl:import element",
111 public static readonly ConformanceRule R2005 = new ConformanceRule (
113 "The targetNamespace attribute on the wsdl:definitions element of a description that is being imported MUST have same the value as the namespace attribute on the wsdl:import element in the importing DESCRIPTION",
116 public static readonly ConformanceRule R2026 = new ConformanceRule (
118 "A DESCRIPTION SHOULD NOT include extension elements with a wsdl:required attribute value of \"true\" on any WSDL construct (wsdl:binding, wsdl:portType, wsdl:message, wsdl:types or wsdl:import) that claims conformance to the Profile",
123 The following rules cannot be checked:
124 R2002, R2003, R4004, R4003
125 There is no access to the unerlying xml