public override void Check(ConformanceCheckContext ctx, ServiceDescriptionFormatExtension value)
 {
     if (value.Required)
     {
         ctx.ReportRuleViolation(value, BasicProfileRules.R2026);
     }
 }
        void CheckR2305(ConformanceCheckContext ctx, Operation value)
        {
            string []          order   = value.ParameterOrder;
            ServiceDescription sd      = value.PortType.ServiceDescription;
            Message            omitted = null;

            foreach (OperationMessage m in value.Messages)
            {
                if (m.Name == null)
                {
                    continue; // it is doubtful, but R2305 is not to check such cases anyways.
                }
                Message msg = sd.Messages [m.Name];
                if (msg == null)
                {
                    continue; // it is doubtful, but R2305 is not to check such cases anyways.
                }
                foreach (MessagePart p in msg.Parts)
                {
                    if (order != null && Array.IndexOf(order, p.Name) >= 0)
                    {
                        continue;
                    }
                    if (omitted == null)
                    {
                        omitted = msg;
                        continue;
                    }
                    ctx.ReportRuleViolation(value, BasicProfileRules.R2305);
                    return;
                }
            }
        }
		public static bool CheckConformance (WsiClaims claims, ServiceDescription service, BasicProfileViolationCollection violations)
		{
			ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
			col.Add (service);
			ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
			return Check (claims, ctx, col);
		}
        // Helper methods

        void CheckWsdlQName(ConformanceCheckContext ctx, object element, XmlQualifiedName name)
        {
            if (name == null || name == XmlQualifiedName.Empty)
            {
                return;
            }
            if (name.Namespace == "" || name.Namespace == XmlSchema.Namespace)
            {
                return;
            }

            if (ctx.ServiceDescription.Types != null && ctx.ServiceDescription.Types.Schemas != null)
            {
                foreach (XmlSchema s in ctx.ServiceDescription.Types.Schemas)
                {
                    if (s.TargetNamespace == name.Namespace)
                    {
                        return;
                    }
                    foreach (XmlSchemaObject i in s.Includes)
                    {
                        if ((i is XmlSchemaImport) && ((XmlSchemaImport)i).Namespace == name.Namespace)
                        {
                            return;
                        }
                    }
                }
            }
            ctx.ReportRuleViolation(element, BasicProfileRules.R2101);
        }
Exemplo n.º 5
0
        internal static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, Binding b)
        {
            checker.Check(ctx, b);
            CheckExtensions(ctx, checker, b.Extensions);

            foreach (OperationBinding oper in b.Operations)
            {
                CheckExtensions(ctx, checker, oper.Extensions);

                foreach (MessageBinding mb in oper.Faults)
                {
                    checker.Check(ctx, mb);
                    CheckExtensions(ctx, checker, mb.Extensions);
                }

                checker.Check(ctx, oper.Input);
                CheckExtensions(ctx, checker, oper.Input.Extensions);

                if (oper.Output != null)
                {
                    checker.Check(ctx, oper.Output);
                    CheckExtensions(ctx, checker, oper.Output.Extensions);
                }
            }
        }
        void CheckSchemaQName(ConformanceCheckContext ctx, object element, XmlQualifiedName name)
        {
            if (name == null || name == XmlQualifiedName.Empty)
            {
                return;
            }
            if (name.Namespace == "" || name.Namespace == XmlSchema.Namespace)
            {
                return;
            }
            if (ctx.CurrentSchema.TargetNamespace == name.Namespace)
            {
                return;
            }

            foreach (XmlSchemaObject i in ctx.CurrentSchema.Includes)
            {
                if ((i is XmlSchemaImport) && ((XmlSchemaImport)i).Namespace == name.Namespace)
                {
                    return;
                }
            }

            ctx.ReportRuleViolation(element, BasicProfileRules.R2102);
        }
Exemplo n.º 7
0
 static void CheckObjects(ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObjectCollection col)
 {
     foreach (XmlSchemaObject item in col)
     {
         Check(ctx, checker, visitedObjects, item);
     }
 }
Exemplo n.º 8
0
		/*
		private string GetAbsoluteUri (string baseUri, string relativeUri)
		{
			string actualBaseUri = baseUri ?? Path.GetFullPath (".") + Path.DirectorySeparatorChar;
			Uri uri = new Uri (new Uri (actualBaseUri), relativeUri);
			return uri.ToString ();
		}
		*/

		public override void Check (ConformanceCheckContext ctx, Import value) 
		{
			if (value.Location == "" || value.Location == null) {
				ctx.ReportRuleViolation (value, BasicProfileRules.R2007);
				return;
			}
			
			if (!new Uri (value.Namespace, UriKind.RelativeOrAbsolute).IsAbsoluteUri)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2803);

			// LAMESPEC: RetrievalUrl does not seem to help here (in .NET)
			//ServiceDescription importer = value.ServiceDescription;
			//string absUri = GetAbsoluteUri (importer != null ? importer.RetrievalUrl : null, value.Location);
			object doc = ctx.GetDocument (/*absUri*/value.Location, value.Namespace);
			if (doc == null) // and looks like .net ignores non-resolvable documentation... I dunno if it makes sense. I don't care :/
				return; //ctx.ReportError (value, "Document '" + value.Location + "' not found");
			
			if (doc is XmlSchema)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2002);
				
			ServiceDescription imported = doc as ServiceDescription;
			if (imported == null) {
				ctx.ReportRuleViolation (value, BasicProfileRules.R2001);
				return;
			}
				
			if (imported.TargetNamespace != value.Namespace)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2005);
		}
		public override void Check (ConformanceCheckContext ctx, MessagePart value)
		{
			CheckWsdlQName (ctx, value, value.Type);
			CheckWsdlQName (ctx, value, value.Element);
			
			if (value.DefinedByElement && value.Element.Namespace == XmlSchema.Namespace)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2206);
		}
 public override void Check(ConformanceCheckContext ctx, XmlSchemaComplexContentRestriction value)
 {
     CheckSchemaQName(ctx, value, value.BaseTypeName);
     if (value.BaseTypeName.Namespace == "http://schemas.xmlsoap.org/soap/encoding/" && value.BaseTypeName.Name == "Array")
     {
         ctx.ReportRuleViolation(value, BasicProfileRules.R2110);
     }
 }
Exemplo n.º 11
0
        public static bool CheckConformance(WsiProfiles claims, ServiceDescription service, BasicProfileViolationCollection violations)
        {
            ServiceDescriptionCollection col = new ServiceDescriptionCollection();

            col.Add(service);
            ConformanceCheckContext ctx = new ConformanceCheckContext(col, violations);

            return(Check(claims, ctx, col));
        }
        public override void Check(ConformanceCheckContext ctx, XmlSchemaImport value)
        {
            // LAMESPEC: same here to Check() for Import.
            XmlSchema doc = ctx.GetDocument(value.SchemaLocation, value.Namespace) as XmlSchema;

            if (doc == null)
            {
                ctx.ReportError(value, "Schema '" + value.SchemaLocation + "' not found");
            }
        }
 public override void Check(ConformanceCheckContext ctx, XmlSchemaElement value)
 {
     CheckSchemaQName(ctx, value, value.RefName);
     CheckSchemaQName(ctx, value, value.SubstitutionGroup);
     CheckSchemaQName(ctx, value, value.SchemaTypeName);
     if (value.Name != null && value.Name.StartsWith("ArrayOf", StringComparison.Ordinal))
     {
         ctx.ReportRuleViolation(value, BasicProfileRules.R2112);
     }
 }
 public override void Check(ConformanceCheckContext ctx, XmlSchemaSimpleTypeUnion value)
 {
     if (value.MemberTypes != null)
     {
         foreach (XmlQualifiedName name in value.MemberTypes)
         {
             CheckSchemaQName(ctx, value, name);
         }
     }
 }
Exemplo n.º 15
0
 static void CheckExtensions(ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescriptionFormatExtensionCollection extensions)
 {
     foreach (object o in extensions)
     {
         ServiceDescriptionFormatExtension ext = o as ServiceDescriptionFormatExtension;
         if (ext != null)
         {
             checker.Check(ctx, ext);
         }
     }
 }
        public override void Check(ConformanceCheckContext ctx, Operation value)
        {
            switch (value.Messages.Flow)
            {
            case OperationFlow.SolicitResponse:
            case OperationFlow.Notification:
                ctx.ReportRuleViolation(value, BasicProfileRules.R2303);
                break;
            }

            CheckR2305(ctx, value);
        }
 public override void Check(ConformanceCheckContext ctx, XmlSchema s)
 {
     if (s.TargetNamespace == null || s.TargetNamespace == "")
     {
         foreach (XmlSchemaObject ob in s.Items)
         {
             if (!(ob is XmlSchemaImport) && !(ob is XmlSchemaAnnotation))
             {
                 ctx.ReportRuleViolation(s, BasicProfileRules.R2105);
                 break;
             }
         }
     }
 }
		static bool Check (WsiClaims claims, ConformanceCheckContext ctx, IEnumerable documents)
		{
			ConformanceChecker[] checkers = GetCheckers (claims);
			if (checkers == null) return true;
			
			foreach (object doc in documents) {
				if (!(doc is ServiceDescription)) continue;
				
				foreach (ConformanceChecker c in checkers)
					Check (ctx, c, (ServiceDescription)doc);
			}
				
			return ctx.Violations.Count == 0;
		}
        public override void Check(ConformanceCheckContext ctx, BindingCollection value)
        {
            foreach (Binding b in value)
            {
                foreach (object ext in b.Extensions)
                {
                    if (ext.GetType() == typeof(SoapBinding))
                    {
                        return;
                    }
                }
            }

            ctx.ReportRuleViolation(value, BasicProfileRules.R2401);
        }
        public override void Check(ConformanceCheckContext ctx, ServiceDescription value)
        {
            // R4005 (and R1034, which turned out to be redundant)
            if (value.Namespaces != null)
            {
                foreach (XmlQualifiedName qname in value.Namespaces.ToArray())
                {
                    if (qname.Namespace == "http://www.w3.org/XML/1998/namespace")
                    {
                        ctx.ReportRuleViolation(value, BasicProfileRules.R4005);
                    }
                }
            }

            CheckDuplicateSoapAddressBinding(ctx, value);
        }
        public override void Check(ConformanceCheckContext ctx, MessagePart value)
        {
            CheckWsdlQName(ctx, value, value.Type);
            CheckWsdlQName(ctx, value, value.Element);

            if (value.DefinedByElement && value.Element.Namespace == XmlSchema.Namespace)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2206);
            }

            if (value.Type != null && value.Type != XmlQualifiedName.Empty &&
                value.Element != null && value.Element != XmlQualifiedName.Empty)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2306);
            }
        }
        public override void Check(ConformanceCheckContext ctx, PortType value)
        {
            ArrayList names = new ArrayList();

            foreach (Operation o in value.Operations)
            {
                if (names.Contains(o.Name))
                {
                    ctx.ReportRuleViolation(value, BasicProfileRules.R2304);
                }
                else
                {
                    names.Add(o.Name);
                }
            }
        }
        public override void Check(ConformanceCheckContext ctx, XmlSchemaAttribute value)
        {
            CheckSchemaQName(ctx, value, value.RefName);
            CheckSchemaQName(ctx, value, value.SchemaTypeName);

            XmlAttribute[] uatts = value.UnhandledAttributes;
            if (uatts != null)
            {
                foreach (XmlAttribute at in uatts)
                {
                    if (at.LocalName == "arrayType" && at.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")
                    {
                        ctx.ReportRuleViolation(value, BasicProfileRules.R2111);
                    }
                }
            }
        }
        void CheckDuplicateSoapAddressBinding(ConformanceCheckContext ctx, ServiceDescription value)
        {
            ArrayList locations = new ArrayList();

            foreach (PortType p in value.PortTypes)
            {
                SoapAddressBinding b = (SoapAddressBinding)p.Extensions.Find(typeof(SoapAddressBinding));
                if (b == null || b.Location == null || b.Location.Length == 0)
                {
                    continue;
                }
                if (locations.Contains(b.Location))
                {
                    ctx.ReportRuleViolation(value, BasicProfileRules.R2711);
                    // One report for one ServiceDescription should be enough.
                    return;
                }
                locations.Add(b.Location);
            }
        }
		internal static void Check (ConformanceCheckContext ctx, ConformanceChecker checker, Binding b)
		{
			checker.Check (ctx, b);
			CheckExtensions (ctx, checker, b.Extensions);

			foreach (OperationBinding oper in b.Operations) {
				CheckExtensions (ctx, checker, oper.Extensions);

				foreach (MessageBinding mb in oper.Faults) {
					checker.Check (ctx, mb);
					CheckExtensions (ctx, checker, mb.Extensions);
				}

				checker.Check (ctx, oper.Input);
				CheckExtensions (ctx, checker, oper.Input.Extensions);

				checker.Check (ctx, oper.Output);
				CheckExtensions (ctx, checker, oper.Output.Extensions);
			}
		}
        /*
         * private string GetAbsoluteUri (string baseUri, string relativeUri)
         * {
         *  string actualBaseUri = baseUri ?? Path.GetFullPath (".") + Path.DirectorySeparatorChar;
         *  Uri uri = new Uri (new Uri (actualBaseUri), relativeUri);
         *  return uri.ToString ();
         * }
         */

        public override void Check(ConformanceCheckContext ctx, Import value)
        {
            if (value.Location == "" || value.Location == null)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2007);
                return;
            }

            if (!new Uri(value.Namespace, UriKind.RelativeOrAbsolute).IsAbsoluteUri)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2803);
            }

            // LAMESPEC: RetrievalUrl does not seem to help here (in .NET)
            //ServiceDescription importer = value.ServiceDescription;
            //string absUri = GetAbsoluteUri (importer != null ? importer.RetrievalUrl : null, value.Location);
            object doc = ctx.GetDocument(/*absUri*/ value.Location, value.Namespace);

            if (doc == null) // and looks like .net ignores non-resolvable documentation... I dunno if it makes sense. I don't care :/
            {
                return;      //ctx.ReportError (value, "Document '" + value.Location + "' not found");
            }
            if (doc is XmlSchema)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2002);
            }

            ServiceDescription imported = doc as ServiceDescription;

            if (imported == null)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2001);
                return;
            }

            if (imported.TargetNamespace != value.Namespace)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2005);
            }
        }
        bool CheckCorrespondingOperationsForBinding(ConformanceCheckContext ctx, Binding value, PortType port)
        {
            if (value.Operations.Count != port.Operations.Count)
            {
                return(true);
            }
            foreach (OperationBinding b in value.Operations)
            {
                Operation op = port.Operations.Find(b.Name);
                if (op == null)
                {
                    return(true);
                }

                bool msg, bind;
                // input
                msg  = op.Messages.Input != null;
                bind = b.Input != null;
                if (msg != bind)
                {
                    return(true);
                }
                // output
                msg  = op.Messages.Output != null;
                bind = b.Output != null;
                if (msg != bind)
                {
                    return(true);
                }
                // faults
                foreach (FaultBinding fb in b.Faults)
                {
                    if (op.Messages.Find(fb.Name) == null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 28
0
        static bool Check(WsiProfiles claims, ConformanceCheckContext ctx, IEnumerable documents)
        {
            ConformanceChecker[] checkers = GetCheckers(claims);
            if (checkers == null)
            {
                return(true);
            }

            foreach (object doc in documents)
            {
                if (!(doc is ServiceDescription))
                {
                    continue;
                }

                foreach (ConformanceChecker c in checkers)
                {
                    Check(ctx, c, (ServiceDescription)doc);
                }
            }

            return(ctx.Violations.Count == 0);
        }
        Message FindMessage(ConformanceCheckContext ctx, MessageBinding mb)
        {
            PortType pt = ctx.Services.GetPortType(mb.OperationBinding.Binding.Type);

            foreach (Operation op in pt.Operations)
            {
                if (op.IsBoundBy(mb.OperationBinding))
                {
                    OperationMessage om;
                    if (mb is InputBinding)
                    {
                        om = op.Messages.Input;
                    }
                    else if (mb is OutputBinding)
                    {
                        om = op.Messages.Output;
                    }
                    else if (mb is FaultBinding)
                    {
                        om = op.Faults [mb.Name];
                    }
                    else
                    {
                        return(null);
                    }
                    if (om != null)
                    {
                        return(ctx.Services.GetMessage(om.Message));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            return(null);
        }
        public override void Check(ConformanceCheckContext ctx, OperationBinding value)
        {
            bool r2754 = false;
            bool r2723 = false;

            foreach (FaultBinding fb in value.Faults)
            {
                SoapFaultBinding sfb = (SoapFaultBinding)value.Extensions.Find(typeof(SoapFaultBinding));
                if (sfb == null)
                {
                    continue;
                }
                r2754 |= sfb.Name != fb.Name;
                r2723 |= sfb.Use == SoapBindingUse.Encoded;
            }
            if (r2754)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2754);
            }
            if (r2723)
            {
                ctx.ReportRuleViolation(value, BasicProfileRules.R2723);
            }
        }
		public override void Check (ConformanceCheckContext ctx, Import value) 
		{
			if (value.Location == "" || value.Location == null) {
				ctx.ReportRuleViolation (value, BasicProfileRules.R2007);
				return;
			}
			
			object doc = ctx.GetDocument (value.Location);
			if (doc == null) ctx.ReportError (value, "Document '" + value.Location + "' not found");
			
			if (doc is XmlSchema)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2002);
				
			ServiceDescription imported = doc as ServiceDescription;
			if (imported == null) {
				ctx.ReportRuleViolation (value, BasicProfileRules.R2001);
				return;
			}
				
			// TODO: rule R2003
			
			if (imported.TargetNamespace != value.Namespace)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2005);
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchema s)
		{
			if (s.TargetNamespace == null || s.TargetNamespace == "") {
				foreach (XmlSchemaObject ob in s.Items)
					if (!(ob is XmlSchemaImport) && !(ob is XmlSchemaAnnotation)) {
						ctx.ReportRuleViolation (s, BasicProfileRules.R2105);
						break;
					}
			}
		}
		static void Check (ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObject value)
		{
			if (value == null) return;
			
			if (visitedObjects.Contains (value)) return;
			visitedObjects.Add (value, value);
			
			if (value is XmlSchemaImport) {
				XmlSchemaImport so = (XmlSchemaImport) value;
				checker.Check (ctx, so);
			}
			else if (value is XmlSchemaAll) {
				XmlSchemaAll so = (XmlSchemaAll) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Items);
			}
			else if (value is XmlSchemaAnnotation) {
				XmlSchemaAnnotation so = (XmlSchemaAnnotation) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Items);
			}
			else if (value is XmlSchemaAttribute) {
				XmlSchemaAttribute so = (XmlSchemaAttribute) value;
				checker.Check (ctx, so);
			}
			else if (value is XmlSchemaAttributeGroup) {
				XmlSchemaAttributeGroup so = (XmlSchemaAttributeGroup) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Attributes);
				Check (ctx, checker, visitedObjects, so.AnyAttribute);
				Check (ctx, checker, visitedObjects, so.RedefinedAttributeGroup);
			}
			else if (value is XmlSchemaAttributeGroupRef) {
				XmlSchemaAttributeGroupRef so = (XmlSchemaAttributeGroupRef) value;
				checker.Check (ctx, so);
			}
			else if (value is XmlSchemaChoice) {
				XmlSchemaChoice so = (XmlSchemaChoice) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Items);
			}
			else if (value is XmlSchemaComplexContent) {
				XmlSchemaComplexContent so = (XmlSchemaComplexContent) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.Content);
			}
			else if (value is XmlSchemaComplexContentExtension) {
				XmlSchemaComplexContentExtension so = (XmlSchemaComplexContentExtension) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.Particle);
				CheckObjects (ctx, checker, visitedObjects, so.Attributes);
				Check (ctx, checker, visitedObjects, so.AnyAttribute);
			}
			else if (value is XmlSchemaComplexContentRestriction) {
				XmlSchemaComplexContentRestriction so = (XmlSchemaComplexContentRestriction) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.Particle);
				CheckObjects (ctx, checker, visitedObjects, so.Attributes);
				Check (ctx, checker, visitedObjects, so.AnyAttribute);
			}
			else if (value is XmlSchemaComplexType) {
				XmlSchemaComplexType so = (XmlSchemaComplexType) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.ContentModel);
				Check (ctx, checker, visitedObjects, so.Particle);
				CheckObjects (ctx, checker, visitedObjects, so.Attributes);
				Check (ctx, checker, visitedObjects, so.AnyAttribute);
				Check (ctx, checker, visitedObjects, so.ContentTypeParticle);
				Check (ctx, checker, visitedObjects, so.AttributeWildcard);
			}
			else if (value is XmlSchemaElement) {
				XmlSchemaElement so = (XmlSchemaElement) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.SchemaType);
				CheckObjects (ctx, checker, visitedObjects, so.Constraints);
			}
			else if (value is XmlSchemaGroup) {
				XmlSchemaGroup so = (XmlSchemaGroup) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.Particle);
			}
			else if (value is XmlSchemaGroupRef) {
				XmlSchemaGroupRef so = (XmlSchemaGroupRef) value;
				checker.Check (ctx, so);
			}
			else if (value is XmlSchemaIdentityConstraint) {
				XmlSchemaIdentityConstraint so = (XmlSchemaIdentityConstraint) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Fields);
				Check (ctx, checker, visitedObjects, so.Selector);
			}
			else if (value is XmlSchemaKeyref) {
				XmlSchemaKeyref so = (XmlSchemaKeyref) value;
				checker.Check (ctx, so);
			}
			else if (value is XmlSchemaRedefine) {
				XmlSchemaRedefine so = (XmlSchemaRedefine) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Items);
			}
			else if (value is XmlSchemaSequence) {
				XmlSchemaSequence so = (XmlSchemaSequence) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Items);
			}
			else if (value is XmlSchemaSimpleContent) {
				XmlSchemaSimpleContent so = (XmlSchemaSimpleContent) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.Content);
			}
			else if (value is XmlSchemaSimpleContentExtension) {
				XmlSchemaSimpleContentExtension so = (XmlSchemaSimpleContentExtension) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Attributes);
				Check (ctx, checker, visitedObjects, so.AnyAttribute);
			}
			else if (value is XmlSchemaSimpleContentRestriction) {
				XmlSchemaSimpleContentRestriction so = (XmlSchemaSimpleContentRestriction) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Attributes);
				Check (ctx, checker, visitedObjects, so.AnyAttribute);
				CheckObjects (ctx, checker, visitedObjects, so.Facets);
			}
			else if (value is XmlSchemaSimpleType) {
				XmlSchemaSimpleType so = (XmlSchemaSimpleType) value;
				checker.Check (ctx, so);
				Check (ctx, checker, visitedObjects, so.Content);
			}
			else if (value is XmlSchemaSimpleTypeList) {
				XmlSchemaSimpleTypeList so = (XmlSchemaSimpleTypeList) value;
				checker.Check (ctx, so);
			}
			else if (value is XmlSchemaSimpleTypeRestriction) {
				XmlSchemaSimpleTypeRestriction so = (XmlSchemaSimpleTypeRestriction) value;
				checker.Check (ctx, so);
				CheckObjects (ctx, checker, visitedObjects, so.Facets);
			}
			else if (value is XmlSchemaSimpleTypeUnion) {
				XmlSchemaSimpleTypeUnion so = (XmlSchemaSimpleTypeUnion) value;
				checker.Check (ctx, so);
			}
		}
Exemplo n.º 34
0
        public static bool CheckConformance(WsiProfiles claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
        {
            ConformanceCheckContext ctx = new ConformanceCheckContext(services, violations);

            return(Check(claims, ctx, services));
        }
		public override void Check (ConformanceCheckContext ctx, XmlSchemaAttribute value)
		{
			CheckSchemaQName (ctx, value, value.RefName);
			CheckSchemaQName (ctx, value, value.SchemaTypeName);
			
			XmlAttribute[] uatts = value.UnhandledAttributes;
			if (uatts != null) {
				foreach (XmlAttribute at in uatts)
					if (at.LocalName == "arrayType" && at.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")
						ctx.ReportRuleViolation (value, BasicProfileRules.R2111);
			}
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchemaComplexContentRestriction value)
		{
			CheckSchemaQName (ctx, value, value.BaseTypeName);
			if (value.BaseTypeName.Namespace == "http://schemas.xmlsoap.org/soap/encoding/" && value.BaseTypeName.Name == "Array")
				ctx.ReportRuleViolation (value, BasicProfileRules.R2110);
		}
		public override void Check (ConformanceCheckContext ctx, ServiceDescription value)
		{
			
		}
		public override void Check (ConformanceCheckContext ctx, ServiceDescriptionFormatExtension value)
		{
			if (value.Required)
				ctx.ReportRuleViolation (value, BasicProfileRules.R2026);
		}
		public override void Check (ConformanceCheckContext ctx, Types value)
		{
		}
		public static bool CheckConformance (WsiClaims claims, WebReference webReference, BasicProfileViolationCollection violations)
		{
			ConformanceCheckContext ctx = new ConformanceCheckContext (webReference, violations);
			return Check (claims, ctx, webReference.Documents.Values);
		}
		static void Check (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescription sd)
		{
			ctx.ServiceDescription = sd;
			ctx.Checker = checker;
			
			checker.Check (ctx, sd);
			CheckExtensions (ctx, checker, sd.Extensions);
			
			foreach (Import i in sd.Imports) {
				checker.Check (ctx, i);
			}
			
			foreach (Service s in sd.Services) {
				checker.Check (ctx, s);
				foreach (Port p in s.Ports) {
					checker.Check (ctx, p);
					CheckExtensions (ctx, checker, p.Extensions);
				}
			}
			
			foreach (Binding b in sd.Bindings)
			{
				checker.Check (ctx, b);
				CheckExtensions (ctx, checker, b.Extensions);
				
				foreach (OperationBinding oper in b.Operations) {
					CheckExtensions (ctx, checker, oper.Extensions);
					
					foreach (MessageBinding mb in oper.Faults) {
						checker.Check (ctx, mb);
						CheckExtensions (ctx, checker, mb.Extensions);
					}
					
					checker.Check (ctx, oper.Input);
					CheckExtensions (ctx, checker, oper.Input.Extensions);
					
					checker.Check (ctx, oper.Output);
					CheckExtensions (ctx, checker, oper.Output.Extensions);
				}
			}
			
			foreach (PortType pt in sd.PortTypes)
			{
				checker.Check (ctx, pt);
				
				foreach (Operation oper in pt.Operations) {
					checker.Check (ctx, oper);
					foreach (OperationMessage msg in oper.Messages)
						checker.Check (ctx, msg);
					
					foreach (OperationMessage msg in oper.Faults)
						checker.Check (ctx, msg);
				}
			}
			
			foreach (Message msg in sd.Messages)
			{
				checker.Check (ctx, msg);
				foreach (MessagePart part in msg.Parts)
					checker.Check (ctx, part);
			}
			
			if (sd.Types != null) {
				checker.Check (ctx, sd.Types);
				if (sd.Types.Schemas != null) {
					foreach (XmlSchema s in sd.Types.Schemas) {
						ctx.CurrentSchema = s;
						checker.Check (ctx, s);
						CheckObjects (ctx, checker, new Hashtable (), s.Items);
					}
				}
			}
		}
		void CheckSchemaQName (ConformanceCheckContext ctx, object element, XmlQualifiedName name)
		{
			if (name == null || name == XmlQualifiedName.Empty) return;
			if (name.Namespace == "" || name.Namespace == XmlSchema.Namespace) return;
			if (ctx.CurrentSchema.TargetNamespace == name.Namespace) return;
			
			foreach (XmlSchemaObject i in ctx.CurrentSchema.Includes)
				if ((i is XmlSchemaImport) && ((XmlSchemaImport)i).Namespace == name.Namespace) return;
				
			ctx.ReportRuleViolation (element, BasicProfileRules.R2102);
		}
Exemplo n.º 43
0
        static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescription sd)
        {
            ctx.ServiceDescription = sd;
            ctx.Checker            = checker;

            checker.Check(ctx, sd);
            CheckExtensions(ctx, checker, sd.Extensions);

            foreach (Import i in sd.Imports)
            {
                checker.Check(ctx, i);
            }

            foreach (Service s in sd.Services)
            {
                checker.Check(ctx, s);
                foreach (Port p in s.Ports)
                {
                    checker.Check(ctx, p);
                    CheckExtensions(ctx, checker, p.Extensions);
                }
            }

            checker.Check(ctx, sd.Bindings);
            foreach (Binding b in sd.Bindings)
            {
                Check(ctx, checker, b);
            }

            foreach (PortType pt in sd.PortTypes)
            {
                checker.Check(ctx, pt);

                foreach (Operation oper in pt.Operations)
                {
                    checker.Check(ctx, oper);
                    foreach (OperationMessage msg in oper.Messages)
                    {
                        checker.Check(ctx, msg);
                    }

                    foreach (OperationMessage msg in oper.Faults)
                    {
                        checker.Check(ctx, msg);
                    }
                }
            }

            foreach (Message msg in sd.Messages)
            {
                checker.Check(ctx, msg);
                foreach (MessagePart part in msg.Parts)
                {
                    checker.Check(ctx, part);
                }
            }

            if (sd.Types != null)
            {
                checker.Check(ctx, sd.Types);
                if (sd.Types.Schemas != null)
                {
                    foreach (XmlSchema s in sd.Types.Schemas)
                    {
                        ctx.CurrentSchema = s;
                        checker.Check(ctx, s);
                        CheckObjects(ctx, checker, new Hashtable(), s.Items);
                    }
                }
            }
        }
		// Helper methods
		
		void CheckWsdlQName (ConformanceCheckContext ctx, object element, XmlQualifiedName name)
		{
			if (name == null || name == XmlQualifiedName.Empty) return;
			if (name.Namespace == "" || name.Namespace == XmlSchema.Namespace) return;
			
			if (ctx.ServiceDescription.Types != null && ctx.ServiceDescription.Types.Schemas != null) 
			{
				foreach (XmlSchema s in ctx.ServiceDescription.Types.Schemas)
				{
					if (s.TargetNamespace == name.Namespace) return;
					foreach (XmlSchemaObject i in s.Includes)
						if ((i is XmlSchemaImport) && ((XmlSchemaImport)i).Namespace == name.Namespace) return;
				}
			}
			ctx.ReportRuleViolation (element, BasicProfileRules.R2101);
		}
Exemplo n.º 45
0
        static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObject value)
        {
            if (value == null)
            {
                return;
            }

            if (visitedObjects.Contains(value))
            {
                return;
            }
            visitedObjects.Add(value, value);

            if (value is XmlSchemaImport)
            {
                XmlSchemaImport so = (XmlSchemaImport)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAll)
            {
                XmlSchemaAll so = (XmlSchemaAll)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAnnotation)
            {
                XmlSchemaAnnotation so = (XmlSchemaAnnotation)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAttribute)
            {
                XmlSchemaAttribute so = (XmlSchemaAttribute)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAttributeGroup)
            {
                XmlSchemaAttributeGroup so = (XmlSchemaAttributeGroup)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.RedefinedAttributeGroup);
            }
            else if (value is XmlSchemaAttributeGroupRef)
            {
                XmlSchemaAttributeGroupRef so = (XmlSchemaAttributeGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaChoice)
            {
                XmlSchemaChoice so = (XmlSchemaChoice)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaComplexContent)
            {
                XmlSchemaComplexContent so = (XmlSchemaComplexContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaComplexContentExtension)
            {
                XmlSchemaComplexContentExtension so = (XmlSchemaComplexContentExtension)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexContentRestriction)
            {
                XmlSchemaComplexContentRestriction so = (XmlSchemaComplexContentRestriction)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexType)
            {
                XmlSchemaComplexType so = (XmlSchemaComplexType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.ContentModel);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.ContentTypeParticle);
                Check(ctx, checker, visitedObjects, so.AttributeWildcard);
            }
            else if (value is XmlSchemaElement)
            {
                XmlSchemaElement so = (XmlSchemaElement)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.SchemaType);
                CheckObjects(ctx, checker, visitedObjects, so.Constraints);
            }
            else if (value is XmlSchemaGroup)
            {
                XmlSchemaGroup so = (XmlSchemaGroup)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
            }
            else if (value is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef so = (XmlSchemaGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaIdentityConstraint)
            {
                XmlSchemaIdentityConstraint so = (XmlSchemaIdentityConstraint)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Fields);
                Check(ctx, checker, visitedObjects, so.Selector);
            }
            else if (value is XmlSchemaKeyref)
            {
                XmlSchemaKeyref so = (XmlSchemaKeyref)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaRedefine)
            {
                XmlSchemaRedefine so = (XmlSchemaRedefine)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSequence)
            {
                XmlSchemaSequence so = (XmlSchemaSequence)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSimpleContent)
            {
                XmlSchemaSimpleContent so = (XmlSchemaSimpleContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleContentExtension)
            {
                XmlSchemaSimpleContentExtension so = (XmlSchemaSimpleContentExtension)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaSimpleContentRestriction)
            {
                XmlSchemaSimpleContentRestriction so = (XmlSchemaSimpleContentRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleType)
            {
                XmlSchemaSimpleType so = (XmlSchemaSimpleType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleTypeList)
            {
                XmlSchemaSimpleTypeList so = (XmlSchemaSimpleTypeList)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaSimpleTypeRestriction)
            {
                XmlSchemaSimpleTypeRestriction so = (XmlSchemaSimpleTypeRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleTypeUnion)
            {
                XmlSchemaSimpleTypeUnion so = (XmlSchemaSimpleTypeUnion)value;
                checker.Check(ctx, so);
            }
        }
		public override void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeUnion value)
		{
			foreach (XmlQualifiedName name in value.MemberTypes)
				CheckSchemaQName (ctx, value, name);
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchemaImport value)
		{
			XmlSchema doc = ctx.GetDocument (value.SchemaLocation) as XmlSchema;
			if (doc == null) ctx.ReportError (value, "Schema '" + value.SchemaLocation + "' not found");
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeRestriction value)
		{
			CheckSchemaQName (ctx, value, value.BaseTypeName);
		}
Exemplo n.º 49
0
        public static bool CheckConformance(WsiProfiles claims, WebReference webReference, BasicProfileViolationCollection violations)
        {
            ConformanceCheckContext ctx = new ConformanceCheckContext(webReference, violations);

            return(Check(claims, ctx, webReference.Documents.Values));
        }
 public override void Check(ConformanceCheckContext ctx, XmlSchemaSimpleTypeRestriction value)
 {
     CheckSchemaQName(ctx, value, value.BaseTypeName);
 }
		static void CheckObjects (ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObjectCollection col)
		{
			foreach (XmlSchemaObject item in col)
				Check (ctx, checker, visitedObjects, item);
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeList value)
		{
			CheckSchemaQName (ctx, value, value.ItemTypeName);
		}
		static void CheckExtensions (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescriptionFormatExtensionCollection extensions)
		{
			foreach (ServiceDescriptionFormatExtension ext in extensions)
				checker.Check (ctx, ext);
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchemaKeyref value)
		{
			CheckSchemaQName (ctx, value, value.Refer);
		}
		public static bool CheckConformance (WsiClaims claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
		{
			ConformanceCheckContext ctx = new ConformanceCheckContext (services, violations);
			return Check (claims, ctx, services);
		}
		public override void Check (ConformanceCheckContext ctx, XmlSchemaGroupRef value)
		{
			CheckSchemaQName (ctx, value, value.RefName);
		}
		public override void Check (ConformanceCheckContext ctx, Service value) { }
		public override void Check (ConformanceCheckContext ctx, XmlSchemaElement value)
		{
			CheckSchemaQName (ctx, value, value.RefName);
			CheckSchemaQName (ctx, value, value.SubstitutionGroup);
			CheckSchemaQName (ctx, value, value.SchemaTypeName);
		}
Exemplo n.º 59
0
		void ImportBinding (ServiceDescription desc, Service service, TypeStubInfo typeInfo, string url, BindingInfo binfo)
		{
			port = new Port ();
			port.Name = portNames.AddUnique (binfo.Name, port);
			bool bindingFull = true;

			if (binfo.Namespace != desc.TargetNamespace)
			{
				if (binfo.Location == null || binfo.Location == string.Empty)
				{
					ServiceDescription newDesc = new ServiceDescription();
					newDesc.TargetNamespace = binfo.Namespace;
					newDesc.Name = binfo.Name;
					bindingFull = ImportBindingContent (newDesc, typeInfo, url, binfo);
					if (bindingFull) {
						int id = ServiceDescriptions.Add (newDesc);
						AddImport (desc, binfo.Namespace, GetWsdlUrl (url,id));
					}
				}
				else {
					AddImport (desc, binfo.Namespace, binfo.Location);
					bindingFull = true;
				}
			}
			else
				bindingFull = ImportBindingContent (desc, typeInfo, url, binfo);
				
			if (bindingFull)
			{
				port.Binding = new XmlQualifiedName (binding.Name, binfo.Namespace);
				
				int n = 0;
				string name = binfo.Name; 
				bool found;
				do {

					found = false;
					foreach (Port p in service.Ports)
						if (p.Name == name) { found = true; n++; name = binfo.Name + n; break; }
				}
				while (found);
				port.Name = name;
				service.Ports.Add (port);
			}

			if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.ConformsTo != WsiProfiles.None && String.IsNullOrEmpty (binfo.WebServiceBindingAttribute.Name)) {
				BasicProfileViolationCollection violations = new BasicProfileViolationCollection ();
				desc.Types.Schemas.Add (Schemas);
				ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
				col.Add (desc);
				ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
				ctx.ServiceDescription = desc;
				ConformanceChecker[] checkers = WebServicesInteroperability.GetCheckers (binfo.WebServiceBindingAttribute.ConformsTo);
				foreach (ConformanceChecker checker in checkers) {
					ctx.Checker = checker;
					WebServicesInteroperability.Check (ctx, checker, binding);
					if (violations.Count > 0)
						throw new InvalidOperationException (violations [0].ToString ());
				}
			}
		}
		public override void Check (ConformanceCheckContext ctx, Message value)
		{
			// TODO: R2113
		}