Beispiel #1
0
		internal void OnServiceDescriptionAdded (ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl)
		{
			serviceDescriptions.Add (serviceDescription);
			ImportInfo info = new ImportInfo (serviceDescription, appSettingUrlKey, appSettingBaseUrl);
			importInfo.Add (info);
			
			if (serviceDescription.Types != null)
				schemas.Add (serviceDescription.Types.Schemas);
		}
Beispiel #2
0
		internal void AddReference (WebReference reference)
		{
			foreach (object doc in reference.Documents.Values)
			{
				if (doc is ServiceDescription) {
					ServiceDescription service = (ServiceDescription) doc;
					ImportInfo info = new ImportInfo (service, reference);
					importInfo.Add (info);
					serviceDescriptions.Add (service);
					
					if (service.Types != null)
						schemas.Add (service.Types.Schemas);
				}
				else if (doc is XmlSchema) {
					schemas.Add ((XmlSchema) doc);
				}
			}
		}
Beispiel #3
0
        void ClasifySchemas(ArrayList importInfo)
        {
            // I don't like this, but I could not find any other way of clasifying
            // schemas between encoded and literal.

            xmlSchemas  = new XmlSchemas();
            soapSchemas = new XmlSchemas();

            foreach (ImportInfo info in importInfo)
            {
                foreach (Service service in info.ServiceDescription.Services)
                {
                    foreach (Port port in service.Ports)
                    {
                        this.iinfo = info;
                        this.port  = port;
                        binding    = ServiceDescriptions.GetBinding(port.Binding);
                        if (binding == null)
                        {
                            continue;
                        }
                        portType = ServiceDescriptions.GetPortType(binding.Type);
                        if (portType == null)
                        {
                            continue;
                        }

                        foreach (OperationBinding oper in binding.Operations)
                        {
                            operationBinding = oper;
                            operation        = FindPortOperation();
                            if (operation == null)
                            {
                                continue;
                            }

                            foreach (OperationMessage omsg in operation.Messages)
                            {
                                Message msg = ServiceDescriptions.GetMessage(omsg.Message);
                                if (msg == null)
                                {
                                    continue;
                                }

                                if (omsg is OperationInput)
                                {
                                    inputMessage = msg;
                                }
                                else
                                {
                                    outputMessage = msg;
                                }
                            }

                            if (GetMessageEncoding(oper.Input) == SoapBindingUse.Encoded)
                            {
                                AddMessageSchema(soapSchemas, oper.Input, inputMessage);
                            }
                            else
                            {
                                AddMessageSchema(xmlSchemas, oper.Input, inputMessage);
                            }

                            if (oper.Output != null)
                            {
                                if (GetMessageEncoding(oper.Output) == SoapBindingUse.Encoded)
                                {
                                    AddMessageSchema(soapSchemas, oper.Output, outputMessage);
                                }
                                else
                                {
                                    AddMessageSchema(xmlSchemas, oper.Output, outputMessage);
                                }
                            }
                        }
                    }
                }
            }

            XmlSchemas defaultList = xmlSchemas;

            if (xmlSchemas.Count == 0 && soapSchemas.Count > 0)
            {
                defaultList = soapSchemas;
            }

            // Schemas not referenced by any message
            foreach (XmlSchema sc in Schemas)
            {
                if (!soapSchemas.Contains(sc) && !xmlSchemas.Contains(sc))
                {
                    if (ImportsEncodedNamespace(sc))
                    {
                        soapSchemas.Add(sc);
                    }
                    else
                    {
                        defaultList.Add(sc);
                    }
                }
            }
        }
Beispiel #4
0
        internal bool Import(ServiceDescriptionImporter descriptionImporter, CodeNamespace codeNamespace, ArrayList importInfo)
        {
            this.descriptionImporter = descriptionImporter;
            this.classNames          = new CodeIdentifiers();;
            this.codeNamespace       = codeNamespace;

            warnings = (ServiceDescriptionImportWarnings)0;

            bool found = false;

            ClasifySchemas(importInfo);

            BeginNamespace();

            foreach (ImportInfo info in importInfo)
            {
                foreach (Service service in info.ServiceDescription.Services)
                {
                    this.service = service;
                    int bindingCount = 0;
                    foreach (Port port in service.Ports)
                    {
                        binding = ServiceDescriptions.GetBinding(port.Binding);
                        if (IsBindingSupported())
                        {
                            bindingCount++;
                        }
                    }

                    foreach (Port port in service.Ports)
                    {
                        this.iinfo = info;
                        this.port  = port;
                        binding    = ServiceDescriptions.GetBinding(port.Binding);
                        if (!IsBindingSupported())
                        {
                            continue;
                        }

                        found = true;
                        ImportPortBinding(bindingCount > 1);
                    }
                }
            }

            if (!found)
            {
                // Looks like MS.NET generates classes for all bindings if
                // no services are present

                foreach (ImportInfo info in importInfo)
                {
                    this.iinfo = info;
                    foreach (Binding b in info.ServiceDescription.Bindings)
                    {
                        this.binding = b;
                        this.service = null;
                        this.port    = null;
                        if (!IsBindingSupported())
                        {
                            continue;
                        }
                        found = true;
                        ImportPortBinding(true);
                    }
                }
            }

            EndNamespace();

            if (!found)
            {
                warnings = ServiceDescriptionImportWarnings.NoCodeGenerated;
            }
            return(found);
        }
		internal void AddReference (WebReference reference)
		{
			foreach (object doc in reference.Documents.Values)
			{
				if (doc is ServiceDescription) {
					ServiceDescription service = (ServiceDescription) doc;
					ImportInfo info = new ImportInfo (service, reference);
					importInfo.Add (info);
					serviceDescriptions.Add (service);
					
					if (service.Types != null)
						schemas.Add (service.Types.Schemas);
				}
				else if (doc is XmlSchema) {
					schemas.Add ((XmlSchema) doc);
				}
			}
		}
		internal void OnServiceDescriptionAdded (ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl)
		{
			serviceDescriptions.Add (serviceDescription);
			ImportInfo info = new ImportInfo (serviceDescription, appSettingUrlKey, appSettingBaseUrl);
			importInfo.Add (info);
			
			if (serviceDescription.Types != null)
				schemas.Add (serviceDescription.Types.Schemas);
		}
		void ClasifySchemas (ArrayList importInfo)
		{
			// I don't like this, but I could not find any other way of clasifying
			// schemas between encoded and literal.
			
			xmlSchemas = new XmlSchemas ();
			soapSchemas = new XmlSchemas ();
			
			foreach (ImportInfo info in importInfo)
			{
				foreach (Service service in info.ServiceDescription.Services)
				{
					foreach (Port port in service.Ports)
					{
						this.iinfo = info;
						this.port = port;
						binding = ServiceDescriptions.GetBinding (port.Binding);
						if (binding == null) continue;
						portType = ServiceDescriptions.GetPortType (binding.Type);
						if (portType == null) continue;
						
						foreach (OperationBinding oper in binding.Operations) 
						{
							operationBinding = oper;
							operation = FindPortOperation ();
							if (operation == null) continue;
		
							foreach (OperationMessage omsg in operation.Messages)
							{
								Message msg = ServiceDescriptions.GetMessage (omsg.Message);
								if (msg == null) continue;
								
								if (omsg is OperationInput)
									inputMessage = msg;
								else
									outputMessage = msg;
							}
							
							if (GetMessageEncoding (oper.Input) == SoapBindingUse.Encoded)
								AddMessageSchema (soapSchemas, oper.Input, inputMessage);
							else
								AddMessageSchema (xmlSchemas, oper.Input, inputMessage);
							
							if (oper.Output != null) {
								if (GetMessageEncoding (oper.Output) == SoapBindingUse.Encoded)
									AddMessageSchema (soapSchemas, oper.Output, outputMessage);
								else
									AddMessageSchema (xmlSchemas, oper.Output, outputMessage);
							}
						}
					}
				}
			}
			
			XmlSchemas defaultList = xmlSchemas;
				
			if (xmlSchemas.Count == 0 && soapSchemas.Count > 0)
				defaultList = soapSchemas;
				
			// Schemas not referenced by any message
			foreach (XmlSchema sc in Schemas)
			{
				if (!soapSchemas.Contains (sc) && !xmlSchemas.Contains (sc)) {
					if (ImportsEncodedNamespace (sc))
						soapSchemas.Add (sc);
					else
						defaultList.Add (sc);
				}
			}
		}
		internal bool Import (ServiceDescriptionImporter descriptionImporter, CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, ArrayList importInfo)
		{
			this.descriptionImporter = descriptionImporter;
			this.classNames = new CodeIdentifiers();;
			this.codeNamespace = codeNamespace;
			this.codeCompileUnit = codeCompileUnit;

			warnings = (ServiceDescriptionImportWarnings) 0;
			
			bool found = false;
			
			ClasifySchemas (importInfo);

			BeginNamespace ();
			
			foreach (ImportInfo info in importInfo)
			{
				foreach (Service service in info.ServiceDescription.Services)
				{
					this.service = service;
					int bindingCount = 0;
					foreach (Port port in service.Ports)
					{
						binding = ServiceDescriptions.GetBinding (port.Binding);
						if (IsBindingSupported ()) bindingCount ++;
					}
					
					foreach (Port port in service.Ports)
					{
						this.iinfo = info;
						this.port = port;
						binding = ServiceDescriptions.GetBinding (port.Binding);
						if (!IsBindingSupported ()) continue;
						
						found = true;
						ImportPortBinding (bindingCount > 1);
					}
				}
			}
			
			if (!found)
			{
				// Looks like MS.NET generates classes for all bindings if
				// no services are present
				
				foreach (ImportInfo info in importInfo)
				{
					this.iinfo = info;
					foreach (Binding b in info.ServiceDescription.Bindings)
					{
						this.binding = b;
						this.service = null;
						this.port = null;
						if (!IsBindingSupported ()) continue;
						found = true;
						ImportPortBinding (true);
					}
				}
			}

			EndNamespace ();
			
			if (!found) warnings = ServiceDescriptionImportWarnings.NoCodeGenerated;
			return true;
		}