Example #1
0
		public ServiceDescriptionImporter ()
		{
			protocolName = String.Empty;
			schemas = new XmlSchemas ();
			serviceDescriptions = new ServiceDescriptionCollection ();
			serviceDescriptions.SetImporter (this);
			style = ServiceDescriptionImportStyle.Client;
		}
		public ServiceDescriptionImporter ()
		{
			protocolName = String.Empty;
			schemas = new XmlSchemas ();
			serviceDescriptions = new ServiceDescriptionCollection ();
			serviceDescriptions.SetImporter (this);
			style = ServiceDescriptionImportStyle.Client;
		}
        private string Write2_ServiceDescriptionImportStyle(ServiceDescriptionImportStyle v)
        {
            switch (v)
            {
                case ServiceDescriptionImportStyle.Client:
                    return "client";

                case ServiceDescriptionImportStyle.Server:
                    return "server";

                case ServiceDescriptionImportStyle.ServerInterface:
                    return "serverInterface";
            }
            long num = (long) v;
            throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "System.Web.Services.Description.ServiceDescriptionImportStyle");
        }
        private string Write2_ServiceDescriptionImportStyle(ServiceDescriptionImportStyle v)
        {
            switch (v)
            {
            case ServiceDescriptionImportStyle.Client:
                return("client");

            case ServiceDescriptionImportStyle.Server:
                return("server");

            case ServiceDescriptionImportStyle.ServerInterface:
                return("serverInterface");
            }
            long num = (long)v;

            throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "System.Web.Services.Description.ServiceDescriptionImportStyle");
        }
Example #5
0
        public static void Main()
        {
            try
            {
                ServiceDescription myServiceDescription =
                    ServiceDescription.Read("Sample_CS.wsdl");

                ServiceDescriptionImporter myImporter =
                    new ServiceDescriptionImporter();

                myImporter.ProtocolName = "Soap";
                myImporter.AddServiceDescription(myServiceDescription, "", "");
                ServiceDescriptionImportStyle myStyle = myImporter.Style;
                Console.WriteLine("Import style: " + myStyle.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("Following exception was thrown: "
                                  + e.ToString());
            }
        }
Example #6
0
        ///
        /// <summary>
        ///	Interperet the command-line arguments and configure the relavent components.
        /// </summary>
        ///
        void ImportArgument(string argument)
        {
            string optionValuePair;

            if (argument.StartsWith("--"))
            {
                optionValuePair = argument.Substring(2);
            }
            else if (argument.StartsWith("/") || argument.StartsWith("-"))
            {
                optionValuePair = argument.Substring(1);
            }
            else
            {
                urls.Add(argument);
                return;
            }

            string option;
            string value;

            int indexOfEquals = optionValuePair.IndexOf(':');

            if (indexOfEquals > 0)
            {
                option = optionValuePair.Substring(0, indexOfEquals);
                value  = optionValuePair.Substring(indexOfEquals + 1);
            }
            else
            {
                option = optionValuePair;
                value  = null;
            }

            switch (option)
            {
            case "appsettingurlkey":
            case "urlkey":
                appSettingURLKey = value;
                break;

            case "appsettingbaseurl":
            case "baseurl":
                appSettingBaseURL = value;
                break;

            case "d":
            case "domain":
                domain = value;
                break;

            case "l":
            case "language":
                language = value;
                break;

            case "n":
            case "namespace":
                ns = value;
                break;

            case "nologo":
                noLogo = true;
                break;

            case "o":
            case "out":
                outFilename = value;
                break;

            case "p":
            case "password":
                password = value;
                break;

            case "protocol":
                protocol = value;
                break;

            case "proxy":
                proxyAddress = value;
                break;

            case "proxydomain":
            case "pd":
                proxyDomain = value;
                break;

            case "proxypassword":
            case "pp":
                proxyPassword = value;
                break;

            case "proxyusername":
            case "pu":
                proxyUsername = value;
                break;

            case "server":
                style = ServiceDescriptionImportStyle.Server;
                break;

            case "u":
            case "username":
                username = value;
                break;

            case "verbose":
                verbose = true;
                break;

            case "fields":
                options &= ~CodeGenerationOptions.GenerateProperties;
                break;

            case "sample":
                sampleSoap = value;
                break;

            case "?":
                help = true;
                break;

            default:
                if (argument.StartsWith("/") && argument.IndexOfAny(Path.InvalidPathChars) == -1)
                {
                    urls.Add(argument);
                    break;
                }
                else
                {
                    throw new Exception("Unknown option " + option);
                }
            }
        }
Example #7
0
		///
		/// <summary>
		///	Interperet the command-line arguments and configure the relavent components.
		/// </summary>
		///		
		void ImportArgument(string argument)
		{
			string optionValuePair;
			
			if (argument.StartsWith("--"))
			{
				optionValuePair = argument.Substring(2);
			}
			else if (argument.StartsWith("/") || argument.StartsWith("-"))
			{
				optionValuePair = argument.Substring(1);
			}
			else
			{
				urls.Add (argument);
				return;
			}
			
			string option;
			string value;
			
			int indexOfEquals = optionValuePair.IndexOf(':');
			if (indexOfEquals > 0)
			{
				option = optionValuePair.Substring(0, indexOfEquals);
				value = optionValuePair.Substring(indexOfEquals + 1);
			}
			else
			{
				option = optionValuePair;
				value = null;
			}
			
			switch (option)
			{
				case "appsettingurlkey":
				case "urlkey":
				    appSettingURLKey = value;
				    break;

				case "appsettingbaseurl":
				case "baseurl":
				    appSettingBaseURL = value;
				    break;

				case "d":
				case "domain":
				    domain = value;
				    break;

				case "l":
				case "language":
				    language = value;
				    break;

				case "n":
				case "namespace":
				    ns = value;
				    break;

				case "nologo":
				    noLogo = true;
				    break;

				case "o":
				case "out":
				    outFilename = value;
				    break;

				case "p":
				case "password":
				    password = value;
				    break;

				case "protocol":
				    protocol = value;
				    break;

				case "proxy":
				    proxyAddress = value;
				    break;

				case "proxydomain":
				case "pd":
				    proxyDomain = value;
				    break;

				case "proxypassword":
				case "pp":
				    proxyPassword = value;
				    break;

				case "proxyusername":
				case "pu":
				    proxyUsername = value;
				    break;

				case "server":
				    style = ServiceDescriptionImportStyle.Server;
				    break;

				case "u":
				case "username":
				    username = value;
				    break;
					
				case "verbose":
					verbose = true;
					break;
					
				case "fields":
					options &= ~CodeGenerationOptions.GenerateProperties;
					break;
					
				case "sample":
					sampleSoap = value;
					break;

				case "?":
				    help = true;
				    break;

				default:
					if (argument.StartsWith ("/") && argument.IndexOfAny (Path.InvalidPathChars) == -1) {
						urls.Add (argument);
						break;
					}
					else
					    throw new Exception("Unknown option " + option);
			}
		}
		public static StringCollection GenerateWebReferences (
			WebReferenceCollection webReferences, 
			CodeGenerationOptions options, 
			ServiceDescriptionImportStyle style, 
			ICodeGenerator codeGenerator, 
			CodeCompileUnit codeCompileUnit, 
			bool verbose)
		{
			StringCollection allWarnings = new StringCollection ();
			ImportContext context = new ImportContext (new CodeIdentifiers(), true);
			
			foreach (WebReference reference in webReferences) 
			{
				ServiceDescriptionImporter importer = new ServiceDescriptionImporter ();
				importer.CodeGenerator = codeGenerator;
				importer.CodeGenerationOptions = options;
				importer.Context = context;
				importer.Style = style;
				importer.ProtocolName = reference.ProtocolName;
				
				importer.AddReference (reference);
				
				reference.Warnings = importer.Import (reference.ProxyCode, codeCompileUnit);
				reference.SetValidationWarnings (context.Warnings);
				foreach (string s in context.Warnings)
					allWarnings.Add (s);

				context.Warnings.Clear ();
			}

			return allWarnings;
		}
		public static StringCollection GenerateWebReferences (
			WebReferenceCollection webReferences, 
			CodeGenerationOptions options, 
			ServiceDescriptionImportStyle style, 
			ICodeGenerator codeGenerator)
		{
			CodeCompileUnit codeCompileUnit = new CodeCompileUnit ();
			return GenerateWebReferences (webReferences, options, style, codeGenerator, codeCompileUnit, false);
		}