private void AddSchemaImports(XmlSchemas schemas, string uri, ServiceDescriptionCollection descriptions)
 {
     int num = 0;
     foreach (XmlSchema schema in schemas)
     {
         if (schema != null)
         {
             if ((schema.Id == null) || (schema.Id.Length == 0))
             {
                 schema.Id = "schema" + ++num.ToString(CultureInfo.InvariantCulture);
             }
             string location = uri + "?schema=" + schema.Id;
             foreach (ServiceDescription description in descriptions)
             {
                 if (description.Types.Schemas.Count == 0)
                 {
                     XmlSchema schema2 = new XmlSchema {
                         TargetNamespace = description.TargetNamespace
                     };
                     schema.ElementFormDefault = XmlSchemaForm.Qualified;
                     this.AddExternal(schema2, schema.TargetNamespace, location);
                     description.Types.Schemas.Add(schema2);
                 }
                 else
                 {
                     this.AddExternal(description.Types.Schemas[0], schema.TargetNamespace, location);
                 }
             }
             this.schemaTable.Add(schema.Id, schema);
         }
     }
 }
		void IWsdlImportExtension.BeforeImport (
			ServiceDescriptionCollection wsdlDocuments,
			XmlSchemaSet xmlSchemas,
			ICollection<XmlElement> policy)
		{
			throw new NotImplementedException ();
		}
        internal Collection <WsdlNS.OperationBinding> GetOperationBindings(WsdlNS.Operation operation)
        {
            Collection <WsdlNS.OperationBinding> bindings;

            if (!_operationBindings.TryGetValue(operation, out bindings))
            {
                bindings = new Collection <WsdlNS.OperationBinding>();
                WsdlNS.ServiceDescriptionCollection wsdlDocuments = WsdlPortType.ServiceDescription.ServiceDescriptions;
                foreach (WsdlNS.ServiceDescription wsdl in wsdlDocuments)
                {
                    foreach (WsdlNS.Binding wsdlBinding in wsdl.Bindings)
                    {
                        if (wsdlBinding.Type.Name == WsdlPortType.Name && wsdlBinding.Type.Namespace == WsdlPortType.ServiceDescription.TargetNamespace)
                        {
                            foreach (WsdlNS.OperationBinding operationBinding in wsdlBinding.Operations)
                            {
                                if (WsdlImporter.Binding2DescriptionHelper.Match(operationBinding, operation) != WsdlImporter.Binding2DescriptionHelper.MatchResult.None)
                                {
                                    bindings.Add(operationBinding);
                                    break;
                                }
                            }
                        }
                    }
                }
                _operationBindings.Add(operation, bindings);
            }
            return(bindings);
        }
		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);
		}
Exemple #5
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);
        }
Exemple #6
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");
            }
        }
		public ServiceDescriptionImporter ()
		{
			protocolName = String.Empty;
			schemas = new XmlSchemas ();
			serviceDescriptions = new ServiceDescriptionCollection ();
			serviceDescriptions.SetImporter (this);
			style = ServiceDescriptionImportStyle.Client;
		}
Exemple #8
0
		public ServiceDescriptionImporter ()
		{
			protocolName = String.Empty;
			schemas = new XmlSchemas ();
			serviceDescriptions = new ServiceDescriptionCollection ();
			serviceDescriptions.SetImporter (this);
			style = ServiceDescriptionImportStyle.Client;
		}
Exemple #9
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));
        }
        void System.ServiceModel.Description.IWsdlImportExtension.BeforeImport(System.Web.Services.Description.ServiceDescriptionCollection wsdlDocuments, System.Xml.Schema.XmlSchemaSet xmlSchemas, System.Collections.Generic.ICollection <System.Xml.XmlElement> policy)
        {
            if (wsdlDocuments == null)
            {
                throw new ArgumentNullException("wsdlDocuments");
            }

            foreach (ServiceDescription document in wsdlDocuments)
            {
                foreach (Service service in document.Services)
                {
                    // We only touch services that have exactly two endpoints
                    // (soap & soap 1.2)
                    if (service.Ports.Count != 2)
                    {
                        continue;
                    }

                    Port portToDelete = null;

                    // Check both ports to see if they are a soap & soap 1.2 pair
                    if (IsSoapAsmxPort(typeof(SoapAddressBinding), service.Ports[0]) && IsSoapAsmxPort(typeof(Soap12AddressBinding), service.Ports[1]))
                    {
                        portToDelete = service.Ports[1];
                    }
                    else if (IsSoapAsmxPort(typeof(SoapAddressBinding), service.Ports[1]) && IsSoapAsmxPort(typeof(Soap12AddressBinding), service.Ports[0]))
                    {
                        portToDelete = service.Ports[0];
                    }

                    if (portToDelete != null)
                    {
                        service.Ports.Remove(portToDelete);

                        if (portToDelete.Binding != null)
                        {
                            // Find any associated bindings so that we can remove
                            // them as well...
                            List <Binding> bindingsToDelete = new List <Binding>();

                            foreach (Binding binding in document.Bindings)
                            {
                                if (String.Equals(binding.Name, portToDelete.Binding.Name, StringComparison.Ordinal))
                                {
                                    bindingsToDelete.Add(binding);
                                }
                            }

                            foreach (Binding bindingToDelete in bindingsToDelete)
                            {
                                document.Bindings.Remove(bindingToDelete);
                            }
                        }
                    }
                }
            }
        }
		void IWsdlImportExtension.BeforeImport (
			ServiceDescriptionCollection wsdlDocuments,
			XmlSchemaSet xmlSchemas,
			ICollection<XmlElement> policy)
		{
			if (!Enabled)
				return;

			impl.BeforeImport (wsdlDocuments, xmlSchemas, policy);
		}
Exemple #12
0
 internal static void EnumerateDocumentedItems(ServiceDescriptionCollection wsdls, Dictionary<string, string> documentedItems)
 {
     foreach (ServiceDescription wsdl in wsdls)
     {
         foreach (XmlSchema schema in wsdl.Types.Schemas)
         {
             EnumerateDocumentedItems(schema.Items, documentedItems);
         }
     }
 }
Exemple #13
0
        public static StringCollection GenerateWebReferences(WebReferenceCollection webReferences, CodeDomProvider codeProvider, System.CodeDom.CodeCompileUnit codeCompileUnit, WebReferenceOptions options)
        {
            if (codeCompileUnit != null)
            {
                codeCompileUnit.ReferencedAssemblies.Add("System.dll");
                codeCompileUnit.ReferencedAssemblies.Add("System.Xml.dll");
                codeCompileUnit.ReferencedAssemblies.Add("System.Web.Services.dll");
                codeCompileUnit.ReferencedAssemblies.Add("System.EnterpriseServices.dll");
            }
            Hashtable namespaces    = new Hashtable();
            Hashtable exportContext = new Hashtable();

            foreach (WebReference reference in webReferences)
            {
                ServiceDescriptionImporter importer = new ServiceDescriptionImporter(codeCompileUnit);
                XmlSchemas schemas = new XmlSchemas();
                ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();
                foreach (DictionaryEntry entry in reference.Documents)
                {
                    AddDocument((string)entry.Key, entry.Value, schemas, descriptions, reference.ValidationWarnings);
                }
                importer.Schemas.Add(schemas);
                foreach (ServiceDescription description in descriptions)
                {
                    importer.AddServiceDescription(description, reference.AppSettingUrlKey, reference.AppSettingBaseUrl);
                }
                importer.CodeGenerator         = codeProvider;
                importer.ProtocolName          = reference.ProtocolName;
                importer.Style                 = options.Style;
                importer.CodeGenerationOptions = options.CodeGenerationOptions;
                foreach (string str in options.SchemaImporterExtensions)
                {
                    importer.Extensions.Add(Type.GetType(str, true));
                }
                System.Xml.Serialization.ImportContext importContext = Context(reference.ProxyCode, namespaces, options.Verbose);
                reference.Warnings = importer.Import(reference.ProxyCode, importContext, exportContext, reference.ValidationWarnings);
                if (reference.ValidationWarnings.Count != 0)
                {
                    reference.Warnings |= ServiceDescriptionImportWarnings.SchemaValidation;
                }
            }
            StringCollection strings = new StringCollection();

            if (options.Verbose)
            {
                foreach (System.Xml.Serialization.ImportContext context2 in namespaces.Values)
                {
                    foreach (string str2 in context2.Warnings)
                    {
                        strings.Add(str2);
                    }
                }
            }
            return(strings);
        }
 internal DocumentationServerType(Type type, string uri) : base(typeof(DocumentationServerProtocol))
 {
     uri = new Uri(uri, true).GetLeftPart(UriPartial.Path);
     this.methodInfo = new LogicalMethodInfo(typeof(DocumentationServerProtocol).GetMethod("Documentation", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance));
     ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();
     reflector.Reflect(type, uri);
     this.schemas = reflector.Schemas;
     this.serviceDescriptions = reflector.ServiceDescriptions;
     this.schemasWithPost = reflector.SchemasWithPost;
     this.serviceDescriptionsWithPost = reflector.ServiceDescriptionsWithPost;
 }
Exemple #15
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));
        }
Exemple #16
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.Reflect"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Reflect(Type type, string url)
        {
            serviceType = type;
            serviceUrl  = url;

            serviceAttr = WebServiceReflector.GetAttribute(type);

            methods = WebMethodReflector.GetMethods(type);
            CheckForDuplicateMethods(methods);

            descriptionsWithPost = descriptions;
            schemasWithPost      = schemas;

            if (reflectorsWithPost != null)
            {
                ReflectInternal(reflectorsWithPost);

                descriptions = new ServiceDescriptionCollection();
                schemas      = new XmlSchemas();
            }

            ReflectInternal(reflectors);

            if (serviceAttr.Description != null && serviceAttr.Description.Length > 0)
            {
                ServiceDescription.Documentation = serviceAttr.Description;
            }

            // need to preprocess all exported schemas to make sure that IXmlSerializable schemas are Merged and the resulting set is valid
            ServiceDescription.Types.Schemas.Compile(null, false);

            if (ServiceDescriptions.Count > 1)
            {
                // if defining interfaces, we move all schemas to the external collection
                // since the types therein may be referenced from any of the sdls
                Schemas.Add(ServiceDescription.Types.Schemas);
                ServiceDescription.Types.Schemas.Clear();
            }
            else if (ServiceDescription.Types.Schemas.Count > 0)
            {
                XmlSchema[] descriptionSchemas = new XmlSchema[ServiceDescription.Types.Schemas.Count];
                ServiceDescription.Types.Schemas.CopyTo(descriptionSchemas, 0);
                foreach (XmlSchema schema in descriptionSchemas)
                {
                    // we always move dataset schemas to the external schema's collection.
                    if (XmlSchemas.IsDataSet(schema))
                    {
                        ServiceDescription.Types.Schemas.Remove(schema);
                        Schemas.Add(schema);
                    }
                }
            }
        }
Exemple #17
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;
 }
		public static ServiceDescriptionCollection GetServiceDescriptions(DiscoveryClientProtocol protocol)
		{
			ServiceDescriptionCollection services = new ServiceDescriptionCollection();
			protocol.ResolveOneLevel();
		
			foreach (DictionaryEntry entry in protocol.References) {
				ContractReference contractRef = entry.Value as ContractReference;
				if (contractRef != null) {
					services.Add(contractRef.Contract);
				}
			}
			return services;
		}
Exemple #19
0
        public ServiceDescription()
        {
            bindings   = new BindingCollection(this);
            extensions = new ServiceDescriptionFormatExtensionCollection(this);
            imports    = new ImportCollection(this);
            messages   = new MessageCollection(this);
            portTypes  = new PortTypeCollection(this);

            serviceDescriptions = null;
            services            = new ServiceCollection(this);
            targetNamespace     = null;
            types = new Types();
        }
Exemple #20
0
        public static ServiceDescription FindRootDescription(ServiceDescriptionCollection wsdls)
        {
            ServiceDescription rootDescription = null;

            //Find the "root" service description
            foreach (System.Web.Services.Description.ServiceDescription description in wsdls)
            {
                if (description.Services.Count > 0)
                {
                    rootDescription = description.Services[0].ServiceDescription;
                    break;
                }
            }
            return rootDescription;
        }
		public void Add(ServiceDescriptionCollection serviceDescriptions)
		{
			if (serviceDescriptions.Count == 0) {
				return;
			}

			webServicesListView.BeginUpdate();
			try {
				foreach (ServiceDescription description in serviceDescriptions) {
					Add(description);
				}
			} finally {
				webServicesListView.EndUpdate();
			}
		}
        public ServiceDescription()
        {
            bindings   = new BindingCollection(this);
            extensions = new ServiceDescriptionFormatExtensionCollection(this);
            imports    = new ImportCollection(this);
            messages   = new MessageCollection(this);
#if !NET_2_0
//			name = String.Empty;
#endif
            portTypes = new PortTypeCollection(this);

            serviceDescriptions = null;
            services            = new ServiceCollection(this);
            targetNamespace     = null;
            types = new Types();
        }
 public ServiceDescriptionImporter()
 {
     this.serviceDescriptions = new ServiceDescriptionCollection();
     this.schemas = new XmlSchemas();
     this.allSchemas = new XmlSchemas();
     this.options = System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync;
     this.abstractSchemas = new XmlSchemas();
     this.concreteSchemas = new XmlSchemas();
     Type[] protocolImporterTypes = WebServicesSection.Current.ProtocolImporterTypes;
     this.importers = new ProtocolImporter[protocolImporterTypes.Length];
     for (int i = 0; i < this.importers.Length; i++)
     {
         this.importers[i] = (ProtocolImporter) Activator.CreateInstance(protocolImporterTypes[i]);
         this.importers[i].Initialize(this);
     }
 }
 internal static void AddDocument(string path, object document, XmlSchemas schemas, ServiceDescriptionCollection descriptions, StringCollection warnings)
 {
     ServiceDescription serviceDescription = document as ServiceDescription;
     if (serviceDescription != null)
     {
         descriptions.Add(serviceDescription);
     }
     else
     {
         XmlSchema schema = document as XmlSchema;
         if (schema != null)
         {
             schemas.Add(schema);
         }
     }
 }
Exemple #25
0
 public ServiceDescriptionImporter()
 {
     this.serviceDescriptions = new ServiceDescriptionCollection();
     this.schemas             = new XmlSchemas();
     this.allSchemas          = new XmlSchemas();
     this.options             = System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync;
     this.abstractSchemas     = new XmlSchemas();
     this.concreteSchemas     = new XmlSchemas();
     Type[] protocolImporterTypes = WebServicesSection.Current.ProtocolImporterTypes;
     this.importers = new ProtocolImporter[protocolImporterTypes.Length];
     for (int i = 0; i < this.importers.Length; i++)
     {
         this.importers[i] = (ProtocolImporter)Activator.CreateInstance(protocolImporterTypes[i]);
         this.importers[i].Initialize(this);
     }
 }
Exemple #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);
        }
        private void EnumerateWsdlsAndSchemas(ServiceDescriptionCollection wsdls, XmlSchemaSet xsds)
        {
            ServiceDescription rootDescription = WsdlUtils.FindRootDescription(wsdls);

            int num = 0;
            foreach (ServiceDescription description2 in wsdls)
            {
                string key = "wsdl";
                if (description2 != rootDescription)
                {
                    key = key + "=wsdl" + num++;
                }
                queryFromDoc.Add(description2, key);
            }
            int num2 = 0;
            foreach (XmlSchema schema in xsds.Schemas())
            {
                string str2 = "xsd=xsd" + num2++;
                queryFromDoc.Add(schema, str2);
            }
        }
Exemple #28
0
 public void Reflect(Type type, string url)
 {
     this.serviceType = type;
     this.serviceUrl  = url;
     this.serviceAttr = WebServiceReflector.GetAttribute(type);
     this.methods     = WebMethodReflector.GetMethods(type);
     this.CheckForDuplicateMethods(this.methods);
     this.descriptionsWithPost = this.descriptions;
     this.schemasWithPost      = this.schemas;
     if (this.reflectorsWithPost != null)
     {
         this.ReflectInternal(this.reflectorsWithPost);
         this.descriptions = new ServiceDescriptionCollection();
         this.schemas      = new XmlSchemas();
     }
     this.ReflectInternal(this.reflectors);
     if ((this.serviceAttr.Description != null) && (this.serviceAttr.Description.Length > 0))
     {
         this.ServiceDescription.Documentation = this.serviceAttr.Description;
     }
     this.ServiceDescription.Types.Schemas.Compile(null, false);
     if (this.ServiceDescriptions.Count > 1)
     {
         this.Schemas.Add(this.ServiceDescription.Types.Schemas);
         this.ServiceDescription.Types.Schemas.Clear();
     }
     else if (this.ServiceDescription.Types.Schemas.Count > 0)
     {
         XmlSchema[] array = new XmlSchema[this.ServiceDescription.Types.Schemas.Count];
         this.ServiceDescription.Types.Schemas.CopyTo(array, 0);
         foreach (XmlSchema schema in array)
         {
             if (XmlSchemas.IsDataSet(schema))
             {
                 this.ServiceDescription.Types.Schemas.Remove(schema);
                 this.Schemas.Add(schema);
             }
         }
     }
 }
Exemple #29
0
 private void AddDocument(string path, object document, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
 {
     ServiceDescription serviceDescription = document as ServiceDescription;
     if (serviceDescription != null)
     {
         if (descriptions[serviceDescription.TargetNamespace] == null)
         {
             descriptions.Add(serviceDescription);
             StringWriter w = new StringWriter();
             XmlTextWriter writer = new XmlTextWriter(w);
             writer.Formatting = Formatting.Indented;
             serviceDescription.Write(writer);
             this.wsdls.Add(w.ToString());
         }
         else
         {
             this.CheckPoint(MessageType.Warning, string.Format(duplicateService, serviceDescription.TargetNamespace, path));
         }
     }
     else
     {
         XmlSchema schema = document as XmlSchema;
         if (schema != null)
         {
             if (schemas[schema.TargetNamespace] == null)
             {
                 schemas.Add(schema);
                 StringWriter writer3 = new StringWriter();
                 XmlTextWriter writer4 = new XmlTextWriter(writer3);
                 writer4.Formatting = Formatting.Indented;
                 schema.Write(writer4);
                 this.xsds.Add(writer3.ToString());
             }
             else
             {
                 this.CheckPoint(MessageType.Warning, string.Format(duplicateSchema, serviceDescription.TargetNamespace, path));
             }
         }
     }
 }
Exemple #30
0
		public static void Generate (ArrayList services, ArrayList schemas, string binOper, string protocol)
		{
			ServiceDescriptionCollection descCol = new ServiceDescriptionCollection ();
			foreach (ServiceDescription sd in services)
				descCol.Add (sd);
				
			XmlSchemas schemaCol;

			if (schemas.Count > 0) {
				schemaCol = new XmlSchemas ();
				foreach (XmlSchema sc in schemas)
					schemaCol.Add (sc);
			}
			else
				schemaCol = descCol[0].Types.Schemas;
				
			string oper, bin = null; 
			
			int i = binOper.IndexOf ('/');
			if (i != -1) {
				oper = binOper.Substring (i+1);
				bin = binOper.Substring (0,i);
			}
			else
				oper = binOper;
			
			ConsoleSampleGenerator sg = new ConsoleSampleGenerator (descCol, schemaCol);
			
			string req, resp;
			sg.GenerateMessages (oper, bin, protocol, out req, out resp);
			
			Console.WriteLine ();
			Console.WriteLine ("Sample request message:");
			Console.WriteLine ();
			Console.WriteLine (req);
			Console.WriteLine ();
			Console.WriteLine ("Sample response message:");
			Console.WriteLine ();
			Console.WriteLine (resp);
		}
Exemple #31
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 void Reflect(Type type, string url)
 {
     this.serviceType = type;
     this.serviceUrl = url;
     this.serviceAttr = WebServiceReflector.GetAttribute(type);
     this.methods = WebMethodReflector.GetMethods(type);
     this.CheckForDuplicateMethods(this.methods);
     this.descriptionsWithPost = this.descriptions;
     this.schemasWithPost = this.schemas;
     if (this.reflectorsWithPost != null)
     {
         this.ReflectInternal(this.reflectorsWithPost);
         this.descriptions = new ServiceDescriptionCollection();
         this.schemas = new XmlSchemas();
     }
     this.ReflectInternal(this.reflectors);
     if ((this.serviceAttr.Description != null) && (this.serviceAttr.Description.Length > 0))
     {
         this.ServiceDescription.Documentation = this.serviceAttr.Description;
     }
     this.ServiceDescription.Types.Schemas.Compile(null, false);
     if (this.ServiceDescriptions.Count > 1)
     {
         this.Schemas.Add(this.ServiceDescription.Types.Schemas);
         this.ServiceDescription.Types.Schemas.Clear();
     }
     else if (this.ServiceDescription.Types.Schemas.Count > 0)
     {
         XmlSchema[] array = new XmlSchema[this.ServiceDescription.Types.Schemas.Count];
         this.ServiceDescription.Types.Schemas.CopyTo(array, 0);
         foreach (XmlSchema schema in array)
         {
             if (XmlSchemas.IsDataSet(schema))
             {
                 this.ServiceDescription.Types.Schemas.Remove(schema);
                 this.Schemas.Add(schema);
             }
         }
     }
 }
Exemple #33
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.Reflect"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Reflect(Type type, string url)
        {
            serviceType = type;
            serviceUrl  = url;

            serviceAttr = WebServiceReflector.GetAttribute(type);

            methods = WebMethodReflector.GetMethods(type);
            CheckForDuplicateMethods(methods);

            descriptionsWithPost = descriptions;
            schemasWithPost      = schemas;

            if (reflectorsWithPost != null)
            {
                ReflectInternal(reflectorsWithPost);

                descriptions = new ServiceDescriptionCollection();
                schemas      = new XmlSchemas();
            }

            ReflectInternal(reflectors);

            XmlSchema[] descriptionSchemas = new XmlSchema[ServiceDescription.Types.Schemas.Count];
            ServiceDescription.Types.Schemas.CopyTo(descriptionSchemas, 0);
            // if defining interfaces, we move all schemas to the external collection
            // since the types therein may be referenced from any of the sdls
            bool externalizeSchemas = ServiceDescriptions.Count > 1;

            foreach (XmlSchema schema in descriptionSchemas)
            {
                // we always move dataset schemas to the external schema's collection.
                if (externalizeSchemas || XmlSchemas.IsDataSet(schema))
                {
                    ServiceDescription.Types.Schemas.Remove(schema);
                    Schemas.Add(schema);
                }
            }
        }
 private void FixImportAddresses(ServiceDescriptionCollection wsdls, ServiceDescription wsdlDoc, XmlSchemaSet schemas)
 {
     foreach (Import import in wsdlDoc.Imports)
     {
         if (string.IsNullOrEmpty(import.Location))
         {
             ServiceDescription description = wsdls[import.Namespace ?? string.Empty];
             if (description != null)
             {
                 string query = queryFromDoc[description];
                 import.Location = this.location + "?" + query;
             }
         }
     }
     if (wsdlDoc.Types != null)
     {
         foreach (XmlSchema schema in wsdlDoc.Types.Schemas)
         {
             this.FixImportAddresses(schemas, schema);
         }
     }
 }
Exemple #35
0
		public WsdlImporter (
			MetadataSet metadata,
			IEnumerable<IPolicyImportExtension> policyImportExtensions,
			IEnumerable<IWsdlImportExtension> wsdlImportExtensions)
			: base (policyImportExtensions)
		{
			if (metadata == null)
				throw new ArgumentNullException ("metadata");
			
			if (wsdlImportExtensions == null) {
				wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> ();

				wsdl_extensions.Add (new DataContractSerializerMessageContractImporter ());
				wsdl_extensions.Add (new XmlSerializerMessageContractImporter ());
				//wsdl_extensions.Add (new MessageEncodingBindingElementImporter ());
				wsdl_extensions.Add (new TransportBindingElementImporter ());
				wsdl_extensions.Add (new StandardBindingImporter ());
			} else {
				wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> (wsdlImportExtensions);
			}

			// It is okay to fill these members immediately when WsdlImporter.ctor() is invoked
			// i.e. after this .ctor(), those metadata docs are not considered anymore.
			this.metadata = metadata;
			this.wsdl_documents = new ServiceDescriptionCollection ();
			this.xmlschemas = new XmlSchemaSet ();
			this.policies = new List<XmlElement> ();

			foreach (MetadataSection ms in metadata.MetadataSections) {
				if (ms.Dialect == MetadataSection.ServiceDescriptionDialect &&
					ms.Metadata.GetType () == typeof (WSServiceDescription))
					wsdl_documents.Add ((WSServiceDescription) ms.Metadata);
				else
				if (ms.Dialect == MetadataSection.XmlSchemaDialect &&
					ms.Metadata.GetType () == typeof (XmlSchema))
					xmlschemas.Add ((XmlSchema) ms.Metadata);
			}
		}
 // See comment on the ServerProtocol.IsCacheUnderPressure method for explanation of the excludeSchemeHostPortFromCachingKey logic.
 internal DocumentationServerType(Type type, string uri, bool excludeSchemeHostPortFromCachingKey)
     : base(typeof(DocumentationServerProtocol))
 {
     if (excludeSchemeHostPortFromCachingKey)
     {
         this.UriFixups = new List<Action<Uri>>();
     }                   
     //
     // parse the uri from a string into a URI object
     //
     Uri uriObject = new Uri(uri, true);
     //
     // and get rid of the query string if there's one
     //
     uri = uriObject.GetLeftPart(UriPartial.Path);
     methodInfo = new LogicalMethodInfo(typeof(DocumentationServerProtocol).GetMethod("Documentation", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
     ServiceDescriptionReflector reflector = new ServiceDescriptionReflector(this.UriFixups);
     reflector.Reflect(type, uri);
     schemas = reflector.Schemas;
     serviceDescriptions = reflector.ServiceDescriptions;
     schemasWithPost = reflector.SchemasWithPost;
     serviceDescriptionsWithPost = reflector.ServiceDescriptionsWithPost;
 }
Exemple #37
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);
                    }
                }
            }
        }
Exemple #38
0
 public void BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, Xml.Schema.XmlSchemaSet xmlSchemas, ICollection <Xml.XmlElement> policy)
 {
     foreach (WsdlNS.ServiceDescription wsdl in wsdlDocuments)
     {
         if (wsdl != null)
         {
             foreach (WsdlNS.Binding wsdlBinding in wsdl.Bindings)
             {
                 if (wsdlBinding != null && wsdlBinding.Extensions != null)
                 {
                     WsdlNS.SoapBinding soapBinding = (WsdlNS.SoapBinding)wsdlBinding.Extensions.Find(typeof(WsdlNS.SoapBinding));
                     if (soapBinding != null)
                     {
                         string transportUri = soapBinding.Transport;
                         if (!string.IsNullOrEmpty(transportUri) && transportUri.Equals(UdpConstants.WsdlSoapUdpTransportUri, StringComparison.Ordinal))
                         {
                             WsdlImporter.SoapInPolicyWorkaroundHelper.InsertAdHocPolicy(wsdlBinding, soapBinding.Transport, this.udpTransportUriKey);
                         }
                     }
                 }
             }
         }
     }
 }
		void IWsdlImportExtension.BeforeImport (
			ServiceDescriptionCollection wsdlDocuments,
			XmlSchemaSet xmlSchemas,
			ICollection<XmlElement> policy)
		{
		}
Exemple #40
0
        /// <include file='doc\ServiceDescriptionImporter.uex' path='docs/doc[@for="ServiceDescriptionImporter.GenerateWebReferences1"]/*' />
        public static StringCollection GenerateWebReferences(WebReferenceCollection webReferences, CodeDomProvider codeProvider, CodeCompileUnit codeCompileUnit, WebReferenceOptions options)
        {
            if (codeCompileUnit != null)
            {
                codeCompileUnit.ReferencedAssemblies.Add("System.dll");
                codeCompileUnit.ReferencedAssemblies.Add("System.Xml.dll");
                codeCompileUnit.ReferencedAssemblies.Add("System.Web.Services.dll");
                codeCompileUnit.ReferencedAssemblies.Add("System.EnterpriseServices.dll");
            }
            Hashtable namespaces       = new Hashtable();
            Hashtable exportedMappings = new Hashtable();

            foreach (WebReference webReference in webReferences)
            {
                ServiceDescriptionImporter importer = new ServiceDescriptionImporter(codeCompileUnit);

                // separate descriptions and schemas
                XmlSchemas schemas = new XmlSchemas();
                ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();

                foreach (DictionaryEntry entry in webReference.Documents)
                {
                    AddDocument((string)entry.Key, entry.Value, schemas, descriptions, webReference.ValidationWarnings);
                }

                importer.Schemas.Add(schemas);
                foreach (ServiceDescription source in descriptions)
                {
                    importer.AddServiceDescription(source, webReference.AppSettingUrlKey, webReference.AppSettingBaseUrl);
                }
                importer.CodeGenerator         = codeProvider;
                importer.ProtocolName          = webReference.ProtocolName;
                importer.Style                 = options.Style;
                importer.CodeGenerationOptions = options.CodeGenerationOptions;
                foreach (string extensionType in options.SchemaImporterExtensions)
                {
                    importer.Extensions.Add(Type.GetType(extensionType, true /*throwOnError*/));
                }
                ImportContext context = Context(webReference.ProxyCode, namespaces, options.Verbose);

                webReference.Warnings = importer.Import(webReference.ProxyCode, context, exportedMappings, webReference.ValidationWarnings);
                if (webReference.ValidationWarnings.Count != 0)
                {
                    webReference.Warnings |= ServiceDescriptionImportWarnings.SchemaValidation;
                }
            }

            StringCollection shareWarnings = new StringCollection();

            if (options.Verbose)
            {
                foreach (ImportContext context in namespaces.Values)
                {
                    foreach (string warning in context.Warnings)
                    {
                        shareWarnings.Add(warning);
                    }
                }
            }
            return(shareWarnings);
        }
Exemple #41
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);
        }
 void IWsdlImportExtension.BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas, ICollection <XmlElement> policy)
 {
     WsdlImporter.SoapInPolicyWorkaroundHelper.InsertAdHocTransportPolicy(wsdlDocuments);
 }
Exemple #43
0
		public ServiceDescription ()
		{
			bindings = new BindingCollection (this);
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
			imports = new ImportCollection (this);
			messages = new MessageCollection (this);
#if !NET_2_0
//			name = String.Empty;		
#endif
			portTypes = new PortTypeCollection (this);

			serviceDescriptions = null;
			services = new ServiceCollection (this);
			targetNamespace = null;
			types = new Types ();
		}
 void DiscoveredWebServices(ServiceDescriptionCollection services)
 {
     ServiceDescriptionMessage = String.Format("{0} service(s) found at address {1}", services.Count, discoveryUri);
     if (services.Count > 0) {
         AddUrlToHistory(discoveryUri);
     }
     DefaultNameSpace = GetDefaultNamespace();
     FillItems(services);
     string referenceName = ServiceReferenceHelper.GetReferenceName(discoveryUri);
 }
 internal void SetParent(ServiceDescriptionCollection parent) {
     this.parent = parent;
 }
 public void BeforeImport(System.Web.Services.Description.ServiceDescriptionCollection wsdlDocuments, System.Xml.Schema.XmlSchemaSet xmlSchemas, ICollection <XmlElement> policy)
 {
 }
Exemple #47
0
        internal static void AddDocument(string path, object document, XmlSchemas schemas, ServiceDescriptionCollection descriptions, StringCollection warnings)
        {
            ServiceDescription serviceDescription = document as ServiceDescription;

            if (serviceDescription != null)
            {
                descriptions.Add(serviceDescription);
            }
            else
            {
                XmlSchema schema = document as XmlSchema;
                if (schema != null)
                {
                    schemas.Add(schema);
                }
            }
        }
        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
        }
 public static StringCollection GenerateWebReferences(WebReferenceCollection webReferences, CodeDomProvider codeProvider, System.CodeDom.CodeCompileUnit codeCompileUnit, WebReferenceOptions options)
 {
     if (codeCompileUnit != null)
     {
         codeCompileUnit.ReferencedAssemblies.Add("System.dll");
         codeCompileUnit.ReferencedAssemblies.Add("System.Xml.dll");
         codeCompileUnit.ReferencedAssemblies.Add("System.Web.Services.dll");
         codeCompileUnit.ReferencedAssemblies.Add("System.EnterpriseServices.dll");
     }
     Hashtable namespaces = new Hashtable();
     Hashtable exportContext = new Hashtable();
     foreach (WebReference reference in webReferences)
     {
         ServiceDescriptionImporter importer = new ServiceDescriptionImporter(codeCompileUnit);
         XmlSchemas schemas = new XmlSchemas();
         ServiceDescriptionCollection descriptions = new ServiceDescriptionCollection();
         foreach (DictionaryEntry entry in reference.Documents)
         {
             AddDocument((string) entry.Key, entry.Value, schemas, descriptions, reference.ValidationWarnings);
         }
         importer.Schemas.Add(schemas);
         foreach (ServiceDescription description in descriptions)
         {
             importer.AddServiceDescription(description, reference.AppSettingUrlKey, reference.AppSettingBaseUrl);
         }
         importer.CodeGenerator = codeProvider;
         importer.ProtocolName = reference.ProtocolName;
         importer.Style = options.Style;
         importer.CodeGenerationOptions = options.CodeGenerationOptions;
         foreach (string str in options.SchemaImporterExtensions)
         {
             importer.Extensions.Add(Type.GetType(str, true));
         }
         System.Xml.Serialization.ImportContext importContext = Context(reference.ProxyCode, namespaces, options.Verbose);
         reference.Warnings = importer.Import(reference.ProxyCode, importContext, exportContext, reference.ValidationWarnings);
         if (reference.ValidationWarnings.Count != 0)
         {
             reference.Warnings |= ServiceDescriptionImportWarnings.SchemaValidation;
         }
     }
     StringCollection strings = new StringCollection();
     if (options.Verbose)
     {
         foreach (System.Xml.Serialization.ImportContext context2 in namespaces.Values)
         {
             foreach (string str2 in context2.Warnings)
             {
                 strings.Add(str2);
             }
         }
     }
     return strings;
 }
 public ServiceDescriptionReflector()
 {
     types = new Types();
     serviceDescriptions = new ServiceDescriptionCollection();
 }
Exemple #51
0
 public SampleGenerator(ServiceDescriptionCollection services, XmlSchemas schemas)
 {
     descriptions = services;
     this.schemas = schemas;
     queue = new ArrayList();
 }
Exemple #52
0
 public void BeforeImport(WS.ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas,
                          ICollection <XmlElement> policy)
 {
 }
        private void ProcessWsdl()
        {
            string           wsdlText;
            string           portType;
            string           bindingName;
            string           address;
            string           spnIdentity       = null;
            string           upnIdentity       = null;
            string           dnsIdentity       = null;
            EndpointIdentity identity          = null;
            string           serializer        = null;
            string           contractNamespace = null;
            string           bindingNamespace  = null;

            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out wsdlText);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Contract, out portType);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Binding, out bindingName);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Address, out address);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.SpnIdentity, out spnIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.UpnIdentity, out upnIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.DnsIdentity, out dnsIdentity);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Serializer, out serializer);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.BindingNamespace, out bindingNamespace);
            propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.ContractNamespace, out contractNamespace);

            if (string.IsNullOrEmpty(wsdlText))
            {
                throw Fx.AssertAndThrow("Wsdl should not be null at this point");
            }
            if (string.IsNullOrEmpty(portType) || string.IsNullOrEmpty(bindingName) || string.IsNullOrEmpty(address))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.ContractBindingAddressCannotBeNull)));
            }

            if (!string.IsNullOrEmpty(spnIdentity))
            {
                if ((!string.IsNullOrEmpty(upnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                }
                identity = EndpointIdentity.CreateSpnIdentity(spnIdentity);
            }
            else if (!string.IsNullOrEmpty(upnIdentity))
            {
                if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(dnsIdentity)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                }
                identity = EndpointIdentity.CreateUpnIdentity(upnIdentity);
            }
            else if (!string.IsNullOrEmpty(dnsIdentity))
            {
                if ((!string.IsNullOrEmpty(spnIdentity)) || (!string.IsNullOrEmpty(upnIdentity)))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorrectServerIdentity)));
                }
                identity = EndpointIdentity.CreateDnsIdentity(dnsIdentity);
            }
            else
            {
                identity = null;
            }

            bool removeXmlSerializerImporter = false;

            if (!String.IsNullOrEmpty(serializer))
            {
                if ("xml" != serializer && "datacontract" != serializer)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.MonikerIncorectSerializer)));
                }

                if ("xml" == serializer)
                {
                    useXmlSerializer = true;
                }
                else
                {
                    removeXmlSerializerImporter = true; // specifying datacontract will explicitly remove the Xml importer
                }
                // if this parameter is not set we will simply use indigo defaults
            }

            TextReader reader = new StringReader(wsdlText);

            try
            {
                try
                {
                    WsdlNS.ServiceDescription wsdl = WsdlNS.ServiceDescription.Read(reader);

                    if (String.IsNullOrEmpty(contractNamespace))
                    {
                        contractNamespace = wsdl.TargetNamespace;
                    }

                    if (String.IsNullOrEmpty(bindingNamespace))
                    {
                        bindingNamespace = wsdl.TargetNamespace;
                    }

                    WsdlNS.ServiceDescriptionCollection wsdlDocs = new WsdlNS.ServiceDescriptionCollection();
                    wsdlDocs.Add(wsdl);
                    XmlSchemaSet schemas = new XmlSchemaSet();
                    foreach (XmlSchema schema in wsdl.Types.Schemas)
                    {
                        schemas.Add(schema);
                    }

                    MetadataSet  mds = new MetadataSet(WsdlImporter.CreateMetadataDocuments(wsdlDocs, schemas, null));
                    WsdlImporter importer;

                    if (useXmlSerializer)
                    {
                        importer = CreateXmlSerializerImporter(mds);
                    }
                    else
                    {
                        if (removeXmlSerializerImporter)
                        {
                            importer = CreateDataContractSerializerImporter(mds);
                        }
                        else
                        {
                            importer = new WsdlImporter(mds);
                        }
                    }

                    XmlQualifiedName contractQname = new XmlQualifiedName(portType, contractNamespace);
                    XmlQualifiedName bindingQname  = new XmlQualifiedName(bindingName, bindingNamespace);

                    WsdlNS.PortType wsdlPortType = wsdlDocs.GetPortType(contractQname);
                    contractDescription = importer.ImportContract(wsdlPortType);

                    WsdlNS.Binding wsdlBinding = wsdlDocs.GetBinding(bindingQname);
                    Binding        binding     = importer.ImportBinding(wsdlBinding);

                    EndpointAddress endpointAddress = new EndpointAddress(new Uri(address), identity, (AddressHeaderCollection)null);

                    serviceEndpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress);

                    ComPlusWsdlChannelBuilderTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationWsdlChannelBuilderLoaded,
                                                         SR.TraceCodeComIntegrationWsdlChannelBuilderLoaded, bindingQname, contractQname, wsdl, contractDescription, binding, wsdl.Types.Schemas);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MonikerSyntaxException(SR.GetString(SR.FailedImportOfWsdl, e.Message)));
                }
            }
            finally
            {
                IDisposable disposee = reader;
                disposee.Dispose();
            }
        }
Exemple #54
0
		static void GenerateWebProxy(string proxyNamespace, string fileName, ServiceDescriptionCollection serviceDescriptions, XmlSchemas schemas, IProject project)
		{
			ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
			
			foreach (ServiceDescription description in serviceDescriptions) {
				importer.AddServiceDescription(description, null, null);
			}
			
			foreach (XmlSchema schema in schemas) {
				importer.Schemas.Add(schema);
			}
			
			CodeNamespace codeNamespace = new CodeNamespace(proxyNamespace);
			CodeCompileUnit codeUnit = new CodeCompileUnit();
			codeUnit.Namespaces.Add(codeNamespace);
			ServiceDescriptionImportWarnings warnings = importer.Import(codeNamespace, codeUnit);
			
			using (StreamWriter sw = new StreamWriter(fileName)) {
				project.GenerateCodeFromCodeDom(codeUnit, sw);
			}
		}
		public static bool CheckConformance (WsiClaims claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
		{
			ConformanceCheckContext ctx = new ConformanceCheckContext (services, violations);
			return Check (claims, ctx, services);
		}
Exemple #56
0
        public static bool CheckConformance(WsiProfiles claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
        {
            ConformanceCheckContext ctx = new ConformanceCheckContext(services, violations);

            return(Check(claims, ctx, services));
        }
 void FillItems(ServiceDescriptionCollection descriptions)
 {
     foreach (ServiceDescription element in descriptions) {
         Add(element);
     }
 }
Exemple #58
0
		internal void SetParent (ServiceDescriptionCollection serviceDescriptions)
		{
			this.serviceDescriptions = serviceDescriptions; 
		}
Exemple #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 ());
				}
			}
		}
 void IWsdlImportExtension.BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas, ICollection <XmlElement> policy)
 {
 }