public void CheckR2305_1 () // bug #443095
		{
			BasicProfileViolationCollection bc = new BasicProfileViolationCollection ();
			WebServicesInteroperability.CheckConformance (
				WsiProfiles.BasicProfile1_1,
				ServiceDescription.Read ("Test/System.Web.Services.Description/443095.wsdl"), bc);
		}
		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);
		}
		public void CheckEmptyOutput () // bug #6041
		{
			BasicProfileViolationCollection bc = new BasicProfileViolationCollection ();
			WebServicesInteroperability.CheckConformance (
				WsiProfiles.BasicProfile1_1,
				ServiceDescription.Read ("Test/System.Web.Services.Description/6041.wsdl"), bc);
		}
		public void ResolveImport () // should not result in an error
		{
			BasicProfileViolationCollection bc = new BasicProfileViolationCollection ();
			WebServicesInteroperability.CheckConformance (
				WsiProfiles.BasicProfile1_1,
				ServiceDescription.Read ("Test/System.Web.Services.Description/check-import.wsdl"), bc);
		}
 public BasicProfileViolationEnumerator(BasicProfileViolationCollection collection)
 {
     if (collection == null)
     {
         throw new ArgumentNullException("collection");
     }
     this.collection = collection;
     generation      = collection.Generation;
 }
 private static void CheckInteroperabilityConformance(WebReference reference, DiscoveryReference result)
 {
     var violations = new BasicProfileViolationCollection();
     WebServicesInteroperability.CheckConformance(WsiProfiles.BasicProfile1_1, reference, violations);
     if (violations.Count > 0)
     {
         result.Warn("This web reference does not conform to WS-I Basic Profile v1.1.");
         foreach (var v in violations)
             result.Warn(v.ToString());
     }
 }
示例#7
0
 public ConformanceCheckContext(ServiceDescriptionCollection collection, BasicProfileViolationCollection violations)
 {
     this.collection = collection;
     this.violations = violations;
     foreach (ServiceDescription sd in collection)
     {
         if (sd.Types != null && sd.Types.Schemas != null)
         {
             schemas.Add(sd.Types.Schemas);
         }
     }
     services = collection;
 }
示例#8
0
 private static void CheckWsdlImports(ServiceDescription description, BasicProfileViolationCollection violations)
 {
     foreach (Import import in description.Imports)
     {
         Uri uri;
         if ((import.Location == null) || (import.Location.Length == 0))
         {
             violations.Add("R2007", System.Web.Services.Res.GetString("Description", new object[] { description.TargetNamespace }));
         }
         string uriString = import.Namespace;
         if ((uriString.Length != 0) && !Uri.TryCreate(uriString, UriKind.Absolute, out uri))
         {
             violations.Add("R2803", System.Web.Services.Res.GetString("Description", new object[] { description.TargetNamespace }));
         }
     }
 }
示例#9
0
 private static void CheckTypes(ServiceDescription description, BasicProfileViolationCollection violations)
 {
     foreach (XmlSchema schema in description.Types.Schemas)
     {
         if ((schema.TargetNamespace == null) || (schema.TargetNamespace.Length == 0))
         {
             using (XmlSchemaObjectEnumerator enumerator2 = schema.Items.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     if (!(enumerator2.Current is XmlSchemaAnnotation))
                     {
                         violations.Add("R2105", System.Web.Services.Res.GetString("Element", new object[] { "schema", description.TargetNamespace }));
                         break;
                     }
                 }
             }
         }
     }
 }
 private static void AddSignature(Hashtable wireSignatures, string name, string ns, string message, string messageNs, BasicProfileViolationCollection violations)
 {
     if (wireSignatures != null)
     {
         string str = ns + ":" + name;
         string element = (string) wireSignatures[str];
         string str3 = ((ns == null) && (name == null)) ? System.Web.Services.Res.GetString("WireSignatureEmpty", new object[] { message, messageNs }) : System.Web.Services.Res.GetString("WireSignature", new object[] { message, messageNs, ns, name });
         if (element != null)
         {
             if (element.Length > 0)
             {
                 violations.Add("R2710", element);
                 violations.Add("R2710", str3);
                 wireSignatures[str] = string.Empty;
             }
         }
         else
         {
             wireSignatures[str] = str3;
         }
     }
 }
示例#11
0
        public ConformanceCheckContext(WebReference webReference, BasicProfileViolationCollection violations)
        {
            this.webReference = webReference;
            this.violations   = violations;
            services          = new ServiceDescriptionCollection();

            foreach (object doc in webReference.Documents.Values)
            {
                if (doc is XmlSchema)
                {
                    schemas.Add((XmlSchema)doc);
                }
                else if (doc is ServiceDescription)
                {
                    ServiceDescription sd = (ServiceDescription)doc;
                    services.Add(sd);
                    if (sd.Types != null && sd.Types.Schemas != null)
                    {
                        schemas.Add(sd.Types.Schemas);
                    }
                }
            }
        }
示例#12
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 NET_2_0
            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());
                    }
                }
            }
#endif
        }
示例#13
0
 public BasicProfileViolationEnumerator(BasicProfileViolationCollection list)
 {
     this.list = list;
     this.idx  = -1;
     this.end  = list.Count - 1;
 }
示例#14
0
		public ConformanceCheckContext (ServiceDescriptionCollection collection, BasicProfileViolationCollection violations)
		{
			this.collection = collection;
			this.violations = violations;
			foreach (ServiceDescription sd in collection) {
				if (sd.Types != null && sd.Types.Schemas != null)
					schemas.Add (sd.Types.Schemas);
			}
			services = collection;
		}
        void ReflectBinding(ReflectedBinding reflectedBinding) {
            string bindingName = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
            string bindingNamespace = reflectedBinding.bindingAttr.Namespace;
            if (bindingName.Length == 0) bindingName = Service.Name + ProtocolName;
            if (bindingNamespace.Length == 0) bindingNamespace = ServiceDescription.TargetNamespace;
            WsiProfiles claims = WsiProfiles.None;
            
            if (reflectedBinding.bindingAttr.Location.Length > 0) {
                // If a URL is specified for the WSDL, file, then we just import the
                // binding from there instead of generating it in this WSDL file.
                portType = null;
                binding = null;
            }
            else {
                bindingServiceDescription = GetServiceDescription(bindingNamespace);
                CodeIdentifiers bindingNames = new CodeIdentifiers();
                foreach (Binding b in bindingServiceDescription.Bindings)
                    bindingNames.AddReserved(b.Name);

                bindingName = bindingNames.AddUnique(bindingName, binding);

                portType = new PortType();
                binding = new Binding();
                portType.Name = bindingName;
                binding.Name = bindingName;
                binding.Type = new XmlQualifiedName(portType.Name, bindingNamespace);
                claims = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
                if (reflectedBinding.bindingAttr.EmitConformanceClaims && claims != WsiProfiles.None) {
                    ServiceDescription.AddConformanceClaims(binding.GetDocumentationElement(), claims);
                }
                bindingServiceDescription.Bindings.Add(binding);
                bindingServiceDescription.PortTypes.Add(portType);
            }
            
            if (portNames == null) {
                portNames = new CodeIdentifiers();
                foreach (Port p in Service.Ports)
                    portNames.AddReserved(p.Name);
            }

            port = new Port();
            port.Binding = new XmlQualifiedName(bindingName, bindingNamespace);
            port.Name = portNames.AddUnique(bindingName, port);
            Service.Ports.Add(port);
            
            BeginClass();

            if (reflectedBinding.methodList != null && reflectedBinding.methodList.Count > 0) {
                foreach (LogicalMethodInfo method in reflectedBinding.methodList) {

                    MoveToMethod(method);

                    operation = new Operation();
                    operation.Name = XmlConvert.EncodeLocalName(method.Name);
                    if (methodAttr.Description != null && methodAttr.Description.Length > 0)
                        operation.Documentation = methodAttr.Description;

                    operationBinding = new OperationBinding();
                    operationBinding.Name = operation.Name;

                    inputMessage = null;
                    outputMessage = null;
                    headerMessages = null;

                    if (ReflectMethod()) {
                        if (inputMessage != null) bindingServiceDescription.Messages.Add(inputMessage);
                        if (outputMessage != null) bindingServiceDescription.Messages.Add(outputMessage);
                        if (headerMessages != null) {
                            foreach (Message headerMessage in headerMessages) {
                                bindingServiceDescription.Messages.Add(headerMessage);
                            }
                        }
                        binding.Operations.Add(operationBinding);
                        portType.Operations.Add(operation);
                    }
                }
            }
            if (binding != null && claims == WsiProfiles.BasicProfile1_1 && ProtocolName == "Soap") {
                BasicProfileViolationCollection warnings = new BasicProfileViolationCollection();
                WebServicesInteroperability.AnalyzeBinding(binding, bindingServiceDescription, ServiceDescriptions, warnings);
                if (warnings.Count > 0) {
                    throw new InvalidOperationException(Res.GetString(Res.WebWsiViolation, ServiceType.FullName, warnings.ToString()));
                }
            }
            EndClass();
        }
 private static void CheckMessageParts(Message message, string[] parts, bool element, string operation, string binding, string ns, Hashtable wireSignatures, BasicProfileViolationCollection violations)
 {
     if (message != null)
     {
         if ((message.Parts == null) || (message.Parts.Count == 0))
         {
             if (!element)
             {
                 AddSignature(wireSignatures, operation, ns, message.Name, ns, violations);
             }
             else
             {
                 AddSignature(wireSignatures, null, null, message.Name, ns, violations);
             }
         }
         else if ((parts == null) || (parts.Length == 0))
         {
             for (int i = 0; i < message.Parts.Count; i++)
             {
                 CheckMessagePart(message.Parts[i], element, message.Name, operation, binding, ns, (i == 0) ? wireSignatures : null, violations);
             }
         }
         else
         {
             for (int j = 0; j < parts.Length; j++)
             {
                 if (parts[j] != null)
                 {
                     MessagePart part1 = message.Parts[parts[j]];
                     CheckMessagePart(message.Parts[j], element, message.Name, operation, binding, ns, (j == 0) ? wireSignatures : null, violations);
                 }
             }
         }
     }
 }
 public static bool CheckConformance(WsiProfiles claims, ServiceDescription description, BasicProfileViolationCollection violations)
 {
     if (description == null)
     {
         throw new ArgumentNullException("description");
     }
     ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();
     descriptions.Add(description);
     return CheckConformance(claims, descriptions, violations);
 }
示例#18
0
        public static bool CheckConformance(WsiProfiles claims, ServiceDescription description, BasicProfileViolationCollection violations)
        {
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }
            ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();

            descriptions.Add(description);
            return(CheckConformance(claims, descriptions, violations));
        }
示例#19
0
        internal static void AnalyzeDescription(ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            bool flag = false;

            foreach (ServiceDescription description in descriptions)
            {
                SchemaCompiler.Compile(description.Types.Schemas);
                CheckWsdlImports(description, violations);
                CheckTypes(description, violations);
                foreach (string str in description.ValidationWarnings)
                {
                    violations.Add("R2028, R2029", str);
                }
                foreach (Binding binding in description.Bindings)
                {
                    flag |= AnalyzeBinding(binding, description, descriptions, violations);
                }
            }
            if (flag)
            {
                CheckExtensions(descriptions, violations);
            }
            else
            {
                violations.Add("Rxxxx");
            }
        }
示例#20
0
 private static void AddSignature(Hashtable wireSignatures, string name, string ns, string message, string messageNs, BasicProfileViolationCollection violations)
 {
     if (wireSignatures != null)
     {
         string str     = ns + ":" + name;
         string element = (string)wireSignatures[str];
         string str3    = ((ns == null) && (name == null)) ? System.Web.Services.Res.GetString("WireSignatureEmpty", new object[] { message, messageNs }) : System.Web.Services.Res.GetString("WireSignature", new object[] { message, messageNs, ns, name });
         if (element != null)
         {
             if (element.Length > 0)
             {
                 violations.Add("R2710", element);
                 violations.Add("R2710", str3);
                 wireSignatures[str] = string.Empty;
             }
         }
         else
         {
             wireSignatures[str] = str3;
         }
     }
 }
 private static SoapBodyBinding FindSoapBodyBinding(bool input, ServiceDescriptionFormatExtensionCollection extensions, BasicProfileViolationCollection violations, bool documentBinding, string operationName, string bindingName, string bindingNs)
 {
     SoapBodyBinding binding = null;
     for (int i = 0; i < extensions.Count; i++)
     {
         object item = extensions[i];
         string uriString = null;
         bool flag = false;
         bool flag2 = false;
         if (item is SoapBodyBinding)
         {
             flag = true;
             binding = (SoapBodyBinding) item;
             uriString = binding.Namespace;
             flag2 = binding.Use == SoapBindingUse.Encoded;
         }
         else if (item is SoapHeaderBinding)
         {
             flag = true;
             SoapHeaderBinding binding2 = (SoapHeaderBinding) item;
             uriString = binding2.Namespace;
             flag2 = binding2.Use == SoapBindingUse.Encoded;
             if (!flag2 && ((binding2.Part == null) || (binding2.Part.Length == 0)))
             {
                 violations.Add("R2720", MessageString(binding2, operationName, bindingName, bindingNs, input, null));
             }
             if (binding2.Fault != null)
             {
                 flag2 |= binding2.Fault.Use == SoapBindingUse.Encoded;
                 if (!flag2)
                 {
                     if ((binding2.Fault.Part == null) || (binding2.Fault.Part.Length == 0))
                     {
                         violations.Add("R2720", MessageString(binding2.Fault, operationName, bindingName, bindingNs, input, null));
                     }
                     if ((binding2.Fault.Namespace != null) && (binding2.Fault.Namespace.Length > 0))
                     {
                         violations.Add(documentBinding ? "R2716" : "R2726", MessageString(item, operationName, bindingName, bindingNs, input, null));
                     }
                 }
             }
         }
         if (flag2)
         {
             violations.Add("R2706", MessageString(item, operationName, bindingName, bindingNs, input, null));
         }
         else if (flag)
         {
             if ((uriString == null) || (uriString.Length == 0))
             {
                 if (!documentBinding && (item is SoapBodyBinding))
                 {
                     violations.Add("R2717", MessageString(item, operationName, bindingName, bindingNs, input, null));
                 }
             }
             else if (documentBinding || !(item is SoapBodyBinding))
             {
                 violations.Add(documentBinding ? "R2716" : "R2726", MessageString(item, operationName, bindingName, bindingNs, input, null));
             }
             else
             {
                 Uri uri;
                 if (!Uri.TryCreate(uriString, UriKind.Absolute, out uri))
                 {
                     violations.Add("R2717", MessageString(item, operationName, bindingName, bindingNs, input, System.Web.Services.Res.GetString("UriValueRelative", new object[] { uriString })));
                 }
             }
         }
     }
     return binding;
 }
 private static void CheckWsdlImports(ServiceDescription description, BasicProfileViolationCollection violations)
 {
     foreach (Import import in description.Imports)
     {
         Uri uri;
         if ((import.Location == null) || (import.Location.Length == 0))
         {
             violations.Add("R2007", System.Web.Services.Res.GetString("Description", new object[] { description.TargetNamespace }));
         }
         string uriString = import.Namespace;
         if ((uriString.Length != 0) && !Uri.TryCreate(uriString, UriKind.Absolute, out uri))
         {
             violations.Add("R2803", System.Web.Services.Res.GetString("Description", new object[] { description.TargetNamespace }));
         }
     }
 }
 private static void CheckTypes(ServiceDescription description, BasicProfileViolationCollection violations)
 {
     foreach (XmlSchema schema in description.Types.Schemas)
     {
         if ((schema.TargetNamespace == null) || (schema.TargetNamespace.Length == 0))
         {
             using (XmlSchemaObjectEnumerator enumerator2 = schema.Items.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     if (!(enumerator2.Current is XmlSchemaAnnotation))
                     {
                         violations.Add("R2105", System.Web.Services.Res.GetString("Element", new object[] { "schema", description.TargetNamespace }));
                         break;
                     }
                 }
             }
         }
     }
 }
示例#24
0
文件: MonoWSDL2.cs 项目: nobled/mono
		///
		/// <summary>
		///	Generate code for the specified ServiceDescription.
		/// </summary>
		///
		public bool GenerateCode (WebReferenceCollection references, CodeCompileUnit codeUnit)
		{
			bool hasWarnings = false;
			
			CodeDomProvider provider = GetProvider();
				
			StringCollection validationWarnings;
			WebReferenceOptions opts = new WebReferenceOptions ();
			opts.CodeGenerationOptions = options;
			opts.Style = style;
			opts.Verbose = verbose;
			validationWarnings = ServiceDescriptionImporter.GenerateWebReferences (references, provider, codeUnit, opts);
			
			for (int n=0; n<references.Count; n++)
			{
				WebReference wr  = references [n];
				
				BasicProfileViolationCollection violations = new BasicProfileViolationCollection ();
				if (String.Compare (protocol, "SOAP", StringComparison.OrdinalIgnoreCase) == 0 && !WebServicesInteroperability.CheckConformance (WsiProfiles.BasicProfile1_1, wr, violations)) {
					wr.Warnings |= ServiceDescriptionImportWarnings.WsiConformance;
				}
				
				if (wr.Warnings != 0)
				{
					if (!hasWarnings) {
						WriteText ("", 0, 0);
						WriteText ("There were some warnings while generating the code:", 0, 0);
					}
					
					WriteText ("", 0, 0);
					WriteText (urls[n], 2, 2);
					
					if ((wr.Warnings & ServiceDescriptionImportWarnings.WsiConformance) > 0) {
						WriteText ("- This web reference does not conform to WS-I Basic Profile v1.1", 4, 6); 
						foreach (BasicProfileViolation vio in violations) {
							WriteText (vio.NormativeStatement + ": " + vio.Details, 8, 8);
							foreach (string ele in vio.Elements)
								WriteText ("* " + ele, 10, 12);
						}
					}
					
					if ((wr.Warnings & ServiceDescriptionImportWarnings.NoCodeGenerated) > 0)
						WriteText ("- WARNING: No proxy class was generated", 4, 6); 
					if ((wr.Warnings & ServiceDescriptionImportWarnings.NoMethodsGenerated) > 0)
						WriteText ("- WARNING: The proxy class generated includes no methods", 4, 6);
					if ((wr.Warnings & ServiceDescriptionImportWarnings.OptionalExtensionsIgnored) > 0)
						WriteText ("- WARNING: At least one optional extension has been ignored", 4, 6);
					if ((wr.Warnings & ServiceDescriptionImportWarnings.RequiredExtensionsIgnored) > 0)
						WriteText ("- WARNING: At least one necessary extension has been ignored", 4, 6);
					if ((wr.Warnings & ServiceDescriptionImportWarnings.UnsupportedBindingsIgnored) > 0)
						WriteText ("- WARNING: At least one binding is of an unsupported type and has been ignored", 4, 6);
					if ((wr.Warnings & ServiceDescriptionImportWarnings.UnsupportedOperationsIgnored) > 0)
						WriteText ("- WARNING: At least one operation is of an unsupported type and has been ignored", 4, 6);
						
					hasWarnings = true;
				}
			}
			
			if (hasWarnings) WriteText ("",0,0);
				
			string filename = outFilename;
			bool hasBindings = false;
			
			foreach (object doc in references[0].Documents.Values)
			{
				ServiceDescription desc = doc as ServiceDescription;
				if (desc == null) continue;
				
				if (desc.Services.Count > 0 && filename == null)
					filename = desc.Services[0].Name + "." + provider.FileExtension;
					
				if (desc.Bindings.Count > 0 || desc.Services.Count > 0)
					hasBindings = true;
			}
			
			if (filename == null)
				filename = "output." + provider.FileExtension;
			
			if (hasBindings) {
				WriteText ("Writing file '" + filename + "'", 0, 0);
				StreamWriter writer = new StreamWriter(filename);
				
				CodeGeneratorOptions compilerOptions = new CodeGeneratorOptions();
				provider.GenerateCodeFromCompileUnit (codeUnit, writer, compilerOptions);
				writer.Close();
			}
			
			return hasWarnings;
		}
示例#25
0
        public static bool CheckConformance(WsiProfiles claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
        {
            ConformanceCheckContext ctx = new ConformanceCheckContext(services, violations);

            return(Check(claims, ctx, services));
        }
示例#26
0
        public static bool CheckConformance(WsiProfiles claims, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            if ((claims & WsiProfiles.BasicProfile1_1) == WsiProfiles.None)
            {
                return(true);
            }
            if (descriptions == null)
            {
                throw new ArgumentNullException("descriptions");
            }
            if (violations == null)
            {
                throw new ArgumentNullException("violations");
            }
            int count = violations.Count;

            AnalyzeDescription(descriptions, violations);
            return(count == violations.Count);
        }
 internal static void AnalyzeDescription(ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
     bool flag = false;
     foreach (ServiceDescription description in descriptions)
     {
         SchemaCompiler.Compile(description.Types.Schemas);
         CheckWsdlImports(description, violations);
         CheckTypes(description, violations);
         foreach (string str in description.ValidationWarnings)
         {
             violations.Add("R2028, R2029", str);
         }
         foreach (Binding binding in description.Bindings)
         {
             flag |= AnalyzeBinding(binding, description, descriptions, violations);
         }
     }
     if (flag)
     {
         CheckExtensions(descriptions, violations);
     }
     else
     {
         violations.Add("Rxxxx");
     }
 }
示例#28
0
        public static bool CheckConformance(WsiProfiles claims, WebReference webReference, BasicProfileViolationCollection violations)
        {
            if ((claims & WsiProfiles.BasicProfile1_1) == WsiProfiles.None)
            {
                return(true);
            }
            if (webReference == null)
            {
                return(true);
            }
            if (violations == null)
            {
                throw new ArgumentNullException("violations");
            }
            XmlSchemas schemas = new XmlSchemas();
            ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();
            StringCollection             warnings     = new StringCollection();

            foreach (DictionaryEntry entry in webReference.Documents)
            {
                ServiceDescriptionImporter.AddDocument((string)entry.Key, entry.Value, schemas, descriptions, warnings);
            }
            int count = violations.Count;

            AnalyzeDescription(descriptions, violations);
            return(count == violations.Count);
        }
 private static void CheckExtensions(ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
     Hashtable hashtable = new Hashtable();
     foreach (ServiceDescription description in descriptions)
     {
         if ((ServiceDescription.GetConformanceClaims(description.Types.DocumentationElement) == WsiProfiles.BasicProfile1_1) && !CheckExtensions(description.Extensions))
         {
             violations.Add("R2026", System.Web.Services.Res.GetString("Element", new object[] { "wsdl:types", description.TargetNamespace }));
         }
         foreach (Service service in description.Services)
         {
             foreach (Port port in service.Ports)
             {
                 if (ServiceDescription.GetConformanceClaims(port.DocumentationElement) == WsiProfiles.BasicProfile1_1)
                 {
                     if (!CheckExtensions(port.Extensions))
                     {
                         violations.Add("R2026", System.Web.Services.Res.GetString("Port", new object[] { port.Name, service.Name, description.TargetNamespace }));
                     }
                     Binding binding = descriptions.GetBinding(port.Binding);
                     if (hashtable[binding] != null)
                     {
                         CheckExtensions(binding, description, violations);
                         hashtable.Add(binding, binding);
                     }
                 }
             }
         }
         foreach (Binding binding2 in description.Bindings)
         {
             SoapBinding binding3 = (SoapBinding) binding2.Extensions.Find(typeof(SoapBinding));
             if (((binding3 != null) && !(binding3.GetType() != typeof(SoapBinding))) && ((hashtable[binding2] == null) && (ServiceDescription.GetConformanceClaims(binding2.DocumentationElement) == WsiProfiles.BasicProfile1_1)))
             {
                 CheckExtensions(binding2, description, violations);
                 hashtable.Add(binding2, binding2);
             }
         }
     }
 }
示例#30
0
        private static void CheckExtensions(ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            Hashtable hashtable = new Hashtable();

            foreach (ServiceDescription description in descriptions)
            {
                if ((ServiceDescription.GetConformanceClaims(description.Types.DocumentationElement) == WsiProfiles.BasicProfile1_1) && !CheckExtensions(description.Extensions))
                {
                    violations.Add("R2026", System.Web.Services.Res.GetString("Element", new object[] { "wsdl:types", description.TargetNamespace }));
                }
                foreach (Service service in description.Services)
                {
                    foreach (Port port in service.Ports)
                    {
                        if (ServiceDescription.GetConformanceClaims(port.DocumentationElement) == WsiProfiles.BasicProfile1_1)
                        {
                            if (!CheckExtensions(port.Extensions))
                            {
                                violations.Add("R2026", System.Web.Services.Res.GetString("Port", new object[] { port.Name, service.Name, description.TargetNamespace }));
                            }
                            Binding binding = descriptions.GetBinding(port.Binding);
                            if (hashtable[binding] != null)
                            {
                                CheckExtensions(binding, description, violations);
                                hashtable.Add(binding, binding);
                            }
                        }
                    }
                }
                foreach (Binding binding2 in description.Bindings)
                {
                    SoapBinding binding3 = (SoapBinding)binding2.Extensions.Find(typeof(SoapBinding));
                    if (((binding3 != null) && !(binding3.GetType() != typeof(SoapBinding))) && ((hashtable[binding2] == null) && (ServiceDescription.GetConformanceClaims(binding2.DocumentationElement) == WsiProfiles.BasicProfile1_1)))
                    {
                        CheckExtensions(binding2, description, violations);
                        hashtable.Add(binding2, binding2);
                    }
                }
            }
        }
 public static bool CheckConformance(WsiProfiles claims, WebReference webReference, BasicProfileViolationCollection violations)
 {
     if ((claims & WsiProfiles.BasicProfile1_1) == WsiProfiles.None)
     {
         return true;
     }
     if (webReference == null)
     {
         return true;
     }
     if (violations == null)
     {
         throw new ArgumentNullException("violations");
     }
     XmlSchemas schemas = new XmlSchemas();
     ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();
     StringCollection warnings = new StringCollection();
     foreach (DictionaryEntry entry in webReference.Documents)
     {
         ServiceDescriptionImporter.AddDocument((string) entry.Key, entry.Value, schemas, descriptions, warnings);
     }
     int count = violations.Count;
     AnalyzeDescription(descriptions, violations);
     return (count == violations.Count);
 }
示例#32
0
        private static void CheckExtensions(Binding binding, ServiceDescription description, BasicProfileViolationCollection violations)
        {
            SoapBinding binding2 = (SoapBinding)binding.Extensions.Find(typeof(SoapBinding));

            if (((binding2 != null) && (binding2.GetType() == typeof(SoapBinding))) && !CheckExtensions(binding.Extensions))
            {
                violations.Add("R2026", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "wsdl:required", "true" }));
            }
        }
示例#33
0
		public ConformanceCheckContext (WebReference webReference, BasicProfileViolationCollection violations)
		{
			this.webReference = webReference;
			this.violations = violations;
			services = new ServiceDescriptionCollection ();
			
			foreach (object doc in webReference.Documents.Values) 
			{
				if (doc is XmlSchema)
					schemas.Add ((XmlSchema)doc);
				else if (doc is ServiceDescription) {
					ServiceDescription sd = (ServiceDescription) doc;
					services.Add (sd);
					if (sd.Types != null && sd.Types.Schemas != null)
						schemas.Add (sd.Types.Schemas);
				}
			}
		}
示例#34
0
 private static void CheckMessagePart(MessagePart part, bool element, string message, string operation, string binding, string ns, Hashtable wireSignatures, BasicProfileViolationCollection violations)
 {
     if (part == null)
     {
         if (!element)
         {
             AddSignature(wireSignatures, operation, ns, message, ns, violations);
         }
         else
         {
             AddSignature(wireSignatures, null, null, message, ns, violations);
         }
     }
     else
     {
         if (((part.Type != null) && !part.Type.IsEmpty) && ((part.Element != null) && !part.Element.IsEmpty))
         {
             violations.Add("R2306", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
         }
         else
         {
             XmlQualifiedName name = ((part.Type == null) || part.Type.IsEmpty) ? part.Element : part.Type;
             if ((name.Namespace == null) || (name.Namespace.Length == 0))
             {
                 violations.Add("R1014", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
             }
         }
         if (!element && ((part.Type == null) || part.Type.IsEmpty))
         {
             violations.Add("R2203", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
         }
         if (element && ((part.Element == null) || part.Element.IsEmpty))
         {
             violations.Add("R2204", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
         }
         if (!element)
         {
             AddSignature(wireSignatures, operation, ns, message, ns, violations);
         }
         else if (part.Element != null)
         {
             AddSignature(wireSignatures, part.Element.Name, part.Element.Namespace, message, ns, violations);
         }
     }
 }
        void ReflectBinding(ReflectedBinding reflectedBinding)
        {
            string bindingName      = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
            string bindingNamespace = reflectedBinding.bindingAttr.Namespace;

            if (bindingName.Length == 0)
            {
                bindingName = Service.Name + ProtocolName;
            }
            if (bindingNamespace.Length == 0)
            {
                bindingNamespace = ServiceDescription.TargetNamespace;
            }
            WsiProfiles claims = WsiProfiles.None;

            if (reflectedBinding.bindingAttr.Location.Length > 0)
            {
                // If a URL is specified for the WSDL, file, then we just import the
                // binding from there instead of generating it in this WSDL file.
                portType = null;
                binding  = null;
            }
            else
            {
                bindingServiceDescription = GetServiceDescription(bindingNamespace);
                CodeIdentifiers bindingNames = new CodeIdentifiers();
                foreach (Binding b in bindingServiceDescription.Bindings)
                {
                    bindingNames.AddReserved(b.Name);
                }

                bindingName = bindingNames.AddUnique(bindingName, binding);

                portType      = new PortType();
                binding       = new Binding();
                portType.Name = bindingName;
                binding.Name  = bindingName;
                binding.Type  = new XmlQualifiedName(portType.Name, bindingNamespace);
                claims        = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
                if (reflectedBinding.bindingAttr.EmitConformanceClaims && claims != WsiProfiles.None)
                {
                    ServiceDescription.AddConformanceClaims(binding.GetDocumentationElement(), claims);
                }
                bindingServiceDescription.Bindings.Add(binding);
                bindingServiceDescription.PortTypes.Add(portType);
            }

            if (portNames == null)
            {
                portNames = new CodeIdentifiers();
                foreach (Port p in Service.Ports)
                {
                    portNames.AddReserved(p.Name);
                }
            }

            port         = new Port();
            port.Binding = new XmlQualifiedName(bindingName, bindingNamespace);
            port.Name    = portNames.AddUnique(bindingName, port);
            Service.Ports.Add(port);

            BeginClass();

            if (reflectedBinding.methodList != null && reflectedBinding.methodList.Count > 0)
            {
                foreach (LogicalMethodInfo method in reflectedBinding.methodList)
                {
                    MoveToMethod(method);

                    operation      = new Operation();
                    operation.Name = XmlConvert.EncodeLocalName(method.Name);
                    if (methodAttr.Description != null && methodAttr.Description.Length > 0)
                    {
                        operation.Documentation = methodAttr.Description;
                    }

                    operationBinding      = new OperationBinding();
                    operationBinding.Name = operation.Name;

                    inputMessage   = null;
                    outputMessage  = null;
                    headerMessages = null;

                    if (ReflectMethod())
                    {
                        if (inputMessage != null)
                        {
                            bindingServiceDescription.Messages.Add(inputMessage);
                        }
                        if (outputMessage != null)
                        {
                            bindingServiceDescription.Messages.Add(outputMessage);
                        }
                        if (headerMessages != null)
                        {
                            foreach (Message headerMessage in headerMessages)
                            {
                                bindingServiceDescription.Messages.Add(headerMessage);
                            }
                        }
                        binding.Operations.Add(operationBinding);
                        portType.Operations.Add(operation);
                    }
                }
            }
            if (binding != null && claims == WsiProfiles.BasicProfile1_1 && ProtocolName == "Soap")
            {
                BasicProfileViolationCollection warnings = new BasicProfileViolationCollection();
                WebServicesInteroperability.AnalyzeBinding(binding, bindingServiceDescription, ServiceDescriptions, warnings);
                if (warnings.Count > 0)
                {
                    throw new InvalidOperationException(Res.GetString(Res.WebWsiViolation, ServiceType.FullName, warnings.ToString()));
                }
            }
            EndClass();
        }
示例#36
0
        internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
        {
            bool        flag     = false;
            bool        flag2    = false;
            SoapBinding binding2 = (SoapBinding)binding.Extensions.Find(typeof(SoapBinding));

            if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding)))
            {
                return(false);
            }
            SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style;

            if (binding2.Transport.Length == 0)
            {
                violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" }));
            }
            else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http")
            {
                violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport }));
            }
            PortType  portType  = descriptions.GetPortType(binding.Type);
            Hashtable hashtable = new Hashtable();

            if (portType != null)
            {
                foreach (Operation operation in portType.Operations)
                {
                    if (operation.Messages.Flow == OperationFlow.Notification)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (operation.Messages.Flow == OperationFlow.SolicitResponse)
                    {
                        violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
                    }
                    if (hashtable[operation.Name] != null)
                    {
                        violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                    }
                    else
                    {
                        OperationBinding binding3 = null;
                        foreach (OperationBinding binding4 in binding.Operations)
                        {
                            if (operation.IsBoundBy(binding4))
                            {
                                if (binding3 != null)
                                {
                                    violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace }));
                                }
                                binding3 = binding4;
                            }
                        }
                        if (binding3 == null)
                        {
                            violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                        }
                        else
                        {
                            hashtable.Add(operation.Name, operation);
                        }
                    }
                }
            }
            Hashtable        wireSignatures = new Hashtable();
            SoapBindingStyle style2         = SoapBindingStyle.Default;

            foreach (OperationBinding binding5 in binding.Operations)
            {
                SoapBindingStyle style3 = style;
                string           name   = binding5.Name;
                if (name != null)
                {
                    if (hashtable[name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                    Operation            operation2 = FindOperation(portType.Operations, binding5);
                    SoapOperationBinding binding6   = (SoapOperationBinding)binding5.Extensions.Find(typeof(SoapOperationBinding));
                    if (binding6 != null)
                    {
                        if (style2 == SoapBindingStyle.Default)
                        {
                            style2 = binding6.Style;
                        }
                        flag  |= style2 != binding6.Style;
                        style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style;
                    }
                    if (binding5.Input != null)
                    {
                        SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded))
                        {
                            Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1));
                                int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length;
                                CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                                if (((num == 0) && (message != null)) && (message.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    if (binding5.Output != null)
                    {
                        SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                        if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded))
                        {
                            Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message));
                            if (style3 == SoapBindingStyle.Rpc)
                            {
                                CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                            }
                            else
                            {
                                flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1));
                                int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length;
                                CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                                if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1))
                                {
                                    violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                                }
                            }
                        }
                    }
                    foreach (FaultBinding binding9 in binding5.Faults)
                    {
                        foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions)
                        {
                            if (extension is SoapFaultBinding)
                            {
                                SoapFaultBinding item = (SoapFaultBinding)extension;
                                if (item.Use == SoapBindingUse.Encoded)
                                {
                                    violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                }
                                else
                                {
                                    if ((item.Name == null) || (item.Name.Length == 0))
                                    {
                                        violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    else if (item.Name != binding9.Name)
                                    {
                                        violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                                    }
                                    if ((item.Namespace != null) && (item.Namespace.Length > 0))
                                    {
                                        violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                                    }
                                }
                            }
                        }
                    }
                    if (hashtable[binding5.Name] == null)
                    {
                        violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
                    }
                }
            }
            if (flag2)
            {
                violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" }));
            }
            if (flag)
            {
                violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace }));
            }
            return(true);
        }
 public static bool CheckConformance(WsiProfiles claims, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
     if ((claims & WsiProfiles.BasicProfile1_1) == WsiProfiles.None)
     {
         return true;
     }
     if (descriptions == null)
     {
         throw new ArgumentNullException("descriptions");
     }
     if (violations == null)
     {
         throw new ArgumentNullException("violations");
     }
     int count = violations.Count;
     AnalyzeDescription(descriptions, violations);
     return (count == violations.Count);
 }
示例#38
0
 private static void CheckMessageParts(Message message, string[] parts, bool element, string operation, string binding, string ns, Hashtable wireSignatures, BasicProfileViolationCollection violations)
 {
     if (message != null)
     {
         if ((message.Parts == null) || (message.Parts.Count == 0))
         {
             if (!element)
             {
                 AddSignature(wireSignatures, operation, ns, message.Name, ns, violations);
             }
             else
             {
                 AddSignature(wireSignatures, null, null, message.Name, ns, violations);
             }
         }
         else if ((parts == null) || (parts.Length == 0))
         {
             for (int i = 0; i < message.Parts.Count; i++)
             {
                 CheckMessagePart(message.Parts[i], element, message.Name, operation, binding, ns, (i == 0) ? wireSignatures : null, violations);
             }
         }
         else
         {
             for (int j = 0; j < parts.Length; j++)
             {
                 if (parts[j] != null)
                 {
                     MessagePart part1 = message.Parts[parts[j]];
                     CheckMessagePart(message.Parts[j], element, message.Name, operation, binding, ns, (j == 0) ? wireSignatures : null, violations);
                 }
             }
         }
     }
 }
        private void ReflectBinding(ReflectedBinding reflectedBinding)
        {
            string identifier = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
            string ns         = reflectedBinding.bindingAttr.Namespace;

            if (identifier.Length == 0)
            {
                identifier = this.Service.Name + this.ProtocolName;
            }
            if (ns.Length == 0)
            {
                ns = this.ServiceDescription.TargetNamespace;
            }
            WsiProfiles none = WsiProfiles.None;

            if (reflectedBinding.bindingAttr.Location.Length > 0)
            {
                this.portType = null;
                this.binding  = null;
            }
            else
            {
                this.bindingServiceDescription = this.GetServiceDescription(ns);
                CodeIdentifiers identifiers = new CodeIdentifiers();
                foreach (System.Web.Services.Description.Binding binding in this.bindingServiceDescription.Bindings)
                {
                    identifiers.AddReserved(binding.Name);
                }
                identifier         = identifiers.AddUnique(identifier, this.binding);
                this.portType      = new System.Web.Services.Description.PortType();
                this.binding       = new System.Web.Services.Description.Binding();
                this.portType.Name = identifier;
                this.binding.Name  = identifier;
                this.binding.Type  = new XmlQualifiedName(this.portType.Name, ns);
                none = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
                if (reflectedBinding.bindingAttr.EmitConformanceClaims && (none != WsiProfiles.None))
                {
                    System.Web.Services.Description.ServiceDescription.AddConformanceClaims(this.binding.GetDocumentationElement(), none);
                }
                this.bindingServiceDescription.Bindings.Add(this.binding);
                this.bindingServiceDescription.PortTypes.Add(this.portType);
            }
            if (this.portNames == null)
            {
                this.portNames = new CodeIdentifiers();
                foreach (System.Web.Services.Description.Port port in this.Service.Ports)
                {
                    this.portNames.AddReserved(port.Name);
                }
            }
            this.port         = new System.Web.Services.Description.Port();
            this.port.Binding = new XmlQualifiedName(identifier, ns);
            this.port.Name    = this.portNames.AddUnique(identifier, this.port);
            this.Service.Ports.Add(this.port);
            this.BeginClass();
            if ((reflectedBinding.methodList != null) && (reflectedBinding.methodList.Count > 0))
            {
                foreach (LogicalMethodInfo info in reflectedBinding.methodList)
                {
                    this.MoveToMethod(info);
                    this.operation      = new System.Web.Services.Description.Operation();
                    this.operation.Name = XmlConvert.EncodeLocalName(info.Name);
                    if ((this.methodAttr.Description != null) && (this.methodAttr.Description.Length > 0))
                    {
                        this.operation.Documentation = this.methodAttr.Description;
                    }
                    this.operationBinding      = new System.Web.Services.Description.OperationBinding();
                    this.operationBinding.Name = this.operation.Name;
                    this.inputMessage          = null;
                    this.outputMessage         = null;
                    this.headerMessages        = null;
                    if (this.ReflectMethod())
                    {
                        if (this.inputMessage != null)
                        {
                            this.bindingServiceDescription.Messages.Add(this.inputMessage);
                        }
                        if (this.outputMessage != null)
                        {
                            this.bindingServiceDescription.Messages.Add(this.outputMessage);
                        }
                        if (this.headerMessages != null)
                        {
                            foreach (Message message in this.headerMessages)
                            {
                                this.bindingServiceDescription.Messages.Add(message);
                            }
                        }
                        this.binding.Operations.Add(this.operationBinding);
                        this.portType.Operations.Add(this.operation);
                    }
                }
            }
            if (((this.binding != null) && (none == WsiProfiles.BasicProfile1_1)) && (this.ProtocolName == "Soap"))
            {
                BasicProfileViolationCollection violations = new BasicProfileViolationCollection();
                WebServicesInteroperability.AnalyzeBinding(this.binding, this.bindingServiceDescription, this.ServiceDescriptions, violations);
                if (violations.Count > 0)
                {
                    throw new InvalidOperationException(System.Web.Services.Res.GetString("WebWsiViolation", new object[] { this.ServiceType.FullName, violations.ToString() }));
                }
            }
            this.EndClass();
        }
		public static bool CheckConformance (WsiClaims claims, WebReference webReference, BasicProfileViolationCollection violations)
		{
			ConformanceCheckContext ctx = new ConformanceCheckContext (webReference, violations);
			return Check (claims, ctx, webReference.Documents.Values);
		}
示例#41
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));
        }
示例#42
0
        private static SoapBodyBinding FindSoapBodyBinding(bool input, ServiceDescriptionFormatExtensionCollection extensions, BasicProfileViolationCollection violations, bool documentBinding, string operationName, string bindingName, string bindingNs)
        {
            SoapBodyBinding binding = null;

            for (int i = 0; i < extensions.Count; i++)
            {
                object item      = extensions[i];
                string uriString = null;
                bool   flag      = false;
                bool   flag2     = false;
                if (item is SoapBodyBinding)
                {
                    flag      = true;
                    binding   = (SoapBodyBinding)item;
                    uriString = binding.Namespace;
                    flag2     = binding.Use == SoapBindingUse.Encoded;
                }
                else if (item is SoapHeaderBinding)
                {
                    flag = true;
                    SoapHeaderBinding binding2 = (SoapHeaderBinding)item;
                    uriString = binding2.Namespace;
                    flag2     = binding2.Use == SoapBindingUse.Encoded;
                    if (!flag2 && ((binding2.Part == null) || (binding2.Part.Length == 0)))
                    {
                        violations.Add("R2720", MessageString(binding2, operationName, bindingName, bindingNs, input, null));
                    }
                    if (binding2.Fault != null)
                    {
                        flag2 |= binding2.Fault.Use == SoapBindingUse.Encoded;
                        if (!flag2)
                        {
                            if ((binding2.Fault.Part == null) || (binding2.Fault.Part.Length == 0))
                            {
                                violations.Add("R2720", MessageString(binding2.Fault, operationName, bindingName, bindingNs, input, null));
                            }
                            if ((binding2.Fault.Namespace != null) && (binding2.Fault.Namespace.Length > 0))
                            {
                                violations.Add(documentBinding ? "R2716" : "R2726", MessageString(item, operationName, bindingName, bindingNs, input, null));
                            }
                        }
                    }
                }
                if (flag2)
                {
                    violations.Add("R2706", MessageString(item, operationName, bindingName, bindingNs, input, null));
                }
                else if (flag)
                {
                    if ((uriString == null) || (uriString.Length == 0))
                    {
                        if (!documentBinding && (item is SoapBodyBinding))
                        {
                            violations.Add("R2717", MessageString(item, operationName, bindingName, bindingNs, input, null));
                        }
                    }
                    else if (documentBinding || !(item is SoapBodyBinding))
                    {
                        violations.Add(documentBinding ? "R2716" : "R2726", MessageString(item, operationName, bindingName, bindingNs, input, null));
                    }
                    else
                    {
                        Uri uri;
                        if (!Uri.TryCreate(uriString, UriKind.Absolute, out uri))
                        {
                            violations.Add("R2717", MessageString(item, operationName, bindingName, bindingNs, input, System.Web.Services.Res.GetString("UriValueRelative", new object[] { uriString })));
                        }
                    }
                }
            }
            return(binding);
        }
示例#43
0
        public static bool CheckConformance(WsiProfiles claims, WebReference webReference, BasicProfileViolationCollection violations)
        {
            ConformanceCheckContext ctx = new ConformanceCheckContext(webReference, violations);

            return(Check(claims, ctx, webReference.Documents.Values));
        }
 private static void CheckMessagePart(MessagePart part, bool element, string message, string operation, string binding, string ns, Hashtable wireSignatures, BasicProfileViolationCollection violations)
 {
     if (part == null)
     {
         if (!element)
         {
             AddSignature(wireSignatures, operation, ns, message, ns, violations);
         }
         else
         {
             AddSignature(wireSignatures, null, null, message, ns, violations);
         }
     }
     else
     {
         if (((part.Type != null) && !part.Type.IsEmpty) && ((part.Element != null) && !part.Element.IsEmpty))
         {
             violations.Add("R2306", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
         }
         else
         {
             XmlQualifiedName name = ((part.Type == null) || part.Type.IsEmpty) ? part.Element : part.Type;
             if ((name.Namespace == null) || (name.Namespace.Length == 0))
             {
                 violations.Add("R1014", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
             }
         }
         if (!element && ((part.Type == null) || part.Type.IsEmpty))
         {
             violations.Add("R2203", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
         }
         if (element && ((part.Element == null) || part.Element.IsEmpty))
         {
             violations.Add("R2204", System.Web.Services.Res.GetString("Part", new object[] { part.Name, message, ns }));
         }
         if (!element)
         {
             AddSignature(wireSignatures, operation, ns, message, ns, violations);
         }
         else if (part.Element != null)
         {
             AddSignature(wireSignatures, part.Element.Name, part.Element.Namespace, message, ns, violations);
         }
     }
 }
 public void Dispose()
 {
     collection = null;
 }
 private static void CheckExtensions(Binding binding, ServiceDescription description, BasicProfileViolationCollection violations)
 {
     SoapBinding binding2 = (SoapBinding) binding.Extensions.Find(typeof(SoapBinding));
     if (((binding2 != null) && (binding2.GetType() == typeof(SoapBinding))) && !CheckExtensions(binding.Extensions))
     {
         violations.Add("R2026", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "wsdl:required", "true" }));
     }
 }
		public static bool CheckConformance (WsiClaims claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
		{
			ConformanceCheckContext ctx = new ConformanceCheckContext (services, violations);
			return Check (claims, ctx, services);
		}
 internal static bool AnalyzeBinding(Binding binding, ServiceDescription description, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
     bool flag = false;
     bool flag2 = false;
     SoapBinding binding2 = (SoapBinding) binding.Extensions.Find(typeof(SoapBinding));
     if ((binding2 == null) || (binding2.GetType() != typeof(SoapBinding)))
     {
         return false;
     }
     SoapBindingStyle style = (binding2.Style == SoapBindingStyle.Default) ? SoapBindingStyle.Document : binding2.Style;
     if (binding2.Transport.Length == 0)
     {
         violations.Add("R2701", System.Web.Services.Res.GetString("BindingMissingAttribute", new object[] { binding.Name, description.TargetNamespace, "transport" }));
     }
     else if (binding2.Transport != "http://schemas.xmlsoap.org/soap/http")
     {
         violations.Add("R2702", System.Web.Services.Res.GetString("BindingInvalidAttribute", new object[] { binding.Name, description.TargetNamespace, "transport", binding2.Transport }));
     }
     PortType portType = descriptions.GetPortType(binding.Type);
     Hashtable hashtable = new Hashtable();
     if (portType != null)
     {
         foreach (Operation operation in portType.Operations)
         {
             if (operation.Messages.Flow == OperationFlow.Notification)
             {
                 violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowNotification", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
             }
             if (operation.Messages.Flow == OperationFlow.SolicitResponse)
             {
                 violations.Add("R2303", System.Web.Services.Res.GetString("OperationFlowSolicitResponse", new object[] { operation.Name, binding.Type.Namespace, binding.Type.Namespace }));
             }
             if (hashtable[operation.Name] != null)
             {
                 violations.Add("R2304", System.Web.Services.Res.GetString("Operation", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
             }
             else
             {
                 OperationBinding binding3 = null;
                 foreach (OperationBinding binding4 in binding.Operations)
                 {
                     if (operation.IsBoundBy(binding4))
                     {
                         if (binding3 != null)
                         {
                             violations.Add("R2304", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding3.Name, binding3.Parent.Name, description.TargetNamespace }));
                         }
                         binding3 = binding4;
                     }
                 }
                 if (binding3 == null)
                 {
                     violations.Add("R2718", System.Web.Services.Res.GetString("OperationMissingBinding", new object[] { operation.Name, binding.Type.Name, binding.Type.Namespace }));
                 }
                 else
                 {
                     hashtable.Add(operation.Name, operation);
                 }
             }
         }
     }
     Hashtable wireSignatures = new Hashtable();
     SoapBindingStyle style2 = SoapBindingStyle.Default;
     foreach (OperationBinding binding5 in binding.Operations)
     {
         SoapBindingStyle style3 = style;
         string name = binding5.Name;
         if (name != null)
         {
             if (hashtable[name] == null)
             {
                 violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
             }
             Operation operation2 = FindOperation(portType.Operations, binding5);
             SoapOperationBinding binding6 = (SoapOperationBinding) binding5.Extensions.Find(typeof(SoapOperationBinding));
             if (binding6 != null)
             {
                 if (style2 == SoapBindingStyle.Default)
                 {
                     style2 = binding6.Style;
                 }
                 flag |= style2 != binding6.Style;
                 style3 = (binding6.Style != SoapBindingStyle.Default) ? binding6.Style : style;
             }
             if (binding5.Input != null)
             {
                 SoapBodyBinding binding7 = FindSoapBodyBinding(true, binding5.Input.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                 if ((binding7 != null) && (binding7.Use != SoapBindingUse.Encoded))
                 {
                     Message message = (operation2 == null) ? null : ((operation2.Messages.Input == null) ? null : descriptions.GetMessage(operation2.Messages.Input.Message));
                     if (style3 == SoapBindingStyle.Rpc)
                     {
                         CheckMessageParts(message, binding7.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                     }
                     else
                     {
                         flag2 = flag2 || ((binding7.Parts != null) && (binding7.Parts.Length > 1));
                         int num = (binding7.Parts == null) ? 0 : binding7.Parts.Length;
                         CheckMessageParts(message, binding7.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, wireSignatures, violations);
                         if (((num == 0) && (message != null)) && (message.Parts.Count > 1))
                         {
                             violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                         }
                     }
                 }
             }
             if (binding5.Output != null)
             {
                 SoapBodyBinding binding8 = FindSoapBodyBinding(false, binding5.Output.Extensions, violations, style3 == SoapBindingStyle.Document, binding5.Name, binding.Name, description.TargetNamespace);
                 if ((binding8 != null) && (binding8.Use != SoapBindingUse.Encoded))
                 {
                     Message message2 = (operation2 == null) ? null : ((operation2.Messages.Output == null) ? null : descriptions.GetMessage(operation2.Messages.Output.Message));
                     if (style3 == SoapBindingStyle.Rpc)
                     {
                         CheckMessageParts(message2, binding8.Parts, false, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                     }
                     else
                     {
                         flag2 = flag2 || ((binding8.Parts != null) && (binding8.Parts.Length > 1));
                         int num2 = (binding8.Parts == null) ? 0 : binding8.Parts.Length;
                         CheckMessageParts(message2, binding8.Parts, true, binding5.Name, binding.Name, description.TargetNamespace, null, violations);
                         if (((num2 == 0) && (message2 != null)) && (message2.Parts.Count > 1))
                         {
                             violations.Add("R2210", System.Web.Services.Res.GetString("OperationBinding", new object[] { binding5.Name, binding.Name, description.TargetNamespace }));
                         }
                     }
                 }
             }
             foreach (FaultBinding binding9 in binding5.Faults)
             {
                 foreach (ServiceDescriptionFormatExtension extension in binding9.Extensions)
                 {
                     if (extension is SoapFaultBinding)
                     {
                         SoapFaultBinding item = (SoapFaultBinding) extension;
                         if (item.Use == SoapBindingUse.Encoded)
                         {
                             violations.Add("R2706", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                         }
                         else
                         {
                             if ((item.Name == null) || (item.Name.Length == 0))
                             {
                                 violations.Add("R2721", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                             }
                             else if (item.Name != binding9.Name)
                             {
                                 violations.Add("R2754", System.Web.Services.Res.GetString("FaultBinding", new object[] { binding9.Name, binding5.Name, binding.Name, description.TargetNamespace }));
                             }
                             if ((item.Namespace != null) && (item.Namespace.Length > 0))
                             {
                                 violations.Add((style3 == SoapBindingStyle.Document) ? "R2716" : "R2726", MessageString(item, binding5.Name, binding.Name, description.TargetNamespace, false, null));
                             }
                         }
                     }
                 }
             }
             if (hashtable[binding5.Name] == null)
             {
                 violations.Add("R2718", System.Web.Services.Res.GetString("PortTypeOperationMissing", new object[] { binding5.Name, binding.Name, description.TargetNamespace, binding.Type.Name, binding.Type.Namespace }));
             }
         }
     }
     if (flag2)
     {
         violations.Add("R2201", System.Web.Services.Res.GetString("BindingMultipleParts", new object[] { binding.Name, description.TargetNamespace, "parts" }));
     }
     if (flag)
     {
         violations.Add("R2705", System.Web.Services.Res.GetString("Binding", new object[] { binding.Name, description.TargetNamespace }));
     }
     return true;
 }
示例#49
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 ());
				}
			}
		}
 private void ReflectBinding(ReflectedBinding reflectedBinding)
 {
     string identifier = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
     string ns = reflectedBinding.bindingAttr.Namespace;
     if (identifier.Length == 0)
     {
         identifier = this.Service.Name + this.ProtocolName;
     }
     if (ns.Length == 0)
     {
         ns = this.ServiceDescription.TargetNamespace;
     }
     WsiProfiles none = WsiProfiles.None;
     if (reflectedBinding.bindingAttr.Location.Length > 0)
     {
         this.portType = null;
         this.binding = null;
     }
     else
     {
         this.bindingServiceDescription = this.GetServiceDescription(ns);
         CodeIdentifiers identifiers = new CodeIdentifiers();
         foreach (System.Web.Services.Description.Binding binding in this.bindingServiceDescription.Bindings)
         {
             identifiers.AddReserved(binding.Name);
         }
         identifier = identifiers.AddUnique(identifier, this.binding);
         this.portType = new System.Web.Services.Description.PortType();
         this.binding = new System.Web.Services.Description.Binding();
         this.portType.Name = identifier;
         this.binding.Name = identifier;
         this.binding.Type = new XmlQualifiedName(this.portType.Name, ns);
         none = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
         if (reflectedBinding.bindingAttr.EmitConformanceClaims && (none != WsiProfiles.None))
         {
             System.Web.Services.Description.ServiceDescription.AddConformanceClaims(this.binding.GetDocumentationElement(), none);
         }
         this.bindingServiceDescription.Bindings.Add(this.binding);
         this.bindingServiceDescription.PortTypes.Add(this.portType);
     }
     if (this.portNames == null)
     {
         this.portNames = new CodeIdentifiers();
         foreach (System.Web.Services.Description.Port port in this.Service.Ports)
         {
             this.portNames.AddReserved(port.Name);
         }
     }
     this.port = new System.Web.Services.Description.Port();
     this.port.Binding = new XmlQualifiedName(identifier, ns);
     this.port.Name = this.portNames.AddUnique(identifier, this.port);
     this.Service.Ports.Add(this.port);
     this.BeginClass();
     if ((reflectedBinding.methodList != null) && (reflectedBinding.methodList.Count > 0))
     {
         foreach (LogicalMethodInfo info in reflectedBinding.methodList)
         {
             this.MoveToMethod(info);
             this.operation = new System.Web.Services.Description.Operation();
             this.operation.Name = XmlConvert.EncodeLocalName(info.Name);
             if ((this.methodAttr.Description != null) && (this.methodAttr.Description.Length > 0))
             {
                 this.operation.Documentation = this.methodAttr.Description;
             }
             this.operationBinding = new System.Web.Services.Description.OperationBinding();
             this.operationBinding.Name = this.operation.Name;
             this.inputMessage = null;
             this.outputMessage = null;
             this.headerMessages = null;
             if (this.ReflectMethod())
             {
                 if (this.inputMessage != null)
                 {
                     this.bindingServiceDescription.Messages.Add(this.inputMessage);
                 }
                 if (this.outputMessage != null)
                 {
                     this.bindingServiceDescription.Messages.Add(this.outputMessage);
                 }
                 if (this.headerMessages != null)
                 {
                     foreach (Message message in this.headerMessages)
                     {
                         this.bindingServiceDescription.Messages.Add(message);
                     }
                 }
                 this.binding.Operations.Add(this.operationBinding);
                 this.portType.Operations.Add(this.operation);
             }
         }
     }
     if (((this.binding != null) && (none == WsiProfiles.BasicProfile1_1)) && (this.ProtocolName == "Soap"))
     {
         BasicProfileViolationCollection violations = new BasicProfileViolationCollection();
         WebServicesInteroperability.AnalyzeBinding(this.binding, this.bindingServiceDescription, this.ServiceDescriptions, violations);
         if (violations.Count > 0)
         {
             throw new InvalidOperationException(System.Web.Services.Res.GetString("WebWsiViolation", new object[] { this.ServiceType.FullName, violations.ToString() }));
         }
     }
     this.EndClass();
 }