public void GetSchemaFiles()
        {
            #region væntigögn ...
            string TEST_DATA_FILE = Path.Combine(TEST_DATA_BASE_FOLDER, this.GetType().Namespace, this.GetType().Name, MethodBase.GetCurrentMethod().Name, EXPECTED_FILE_NAME);
            List <Pair <string, Triple <string, string, string> > > test_data = TestUtilities.ReadObjectFromFile <List <Pair <string, Triple <string, string, string> > > >(TEST_DATA_FILE);
            #endregion

            foreach (Pair <string, Triple <string, string, string> > wsdl_and_expected_schemafiles in test_data)
            {
                #region inntak tíundað ...
                TestUtilities.ReportObject <string>(String.Format("Inntak {0}", MethodBase.GetCurrentMethod().Name), wsdl_and_expected_schemafiles.First);
                #endregion

                Tuple <string, string, string> schema_files = WebServiceParser.GetSchemaFiles(wsdl_and_expected_schemafiles.First);

                #region úttak lítillega meðhöndlað ...
                Triple <string, string, string> actual = new Triple <string, string, string>(schema_files.Item1, schema_files.Item2, schema_files.Item3);
                #endregion

                #region úttak tíundað ...
                TestUtilities.ReportObject <Triple <string, string, string> >(String.Format("Úttak {0}", MethodBase.GetCurrentMethod().Name), actual);
                #endregion

                #region samanburður vænti- og raungagna ...
                Assert.IsTrue(wsdl_and_expected_schemafiles.Second.Equals(actual));
                #endregion
            }
        }
Example #2
0
        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            HttpRequest request     = context.Request;
            string      contentType = request.ContentType;

            if (!String.IsNullOrEmpty(contentType) && contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
            {
                Type handlerType = null;
                if (url.EndsWith(ProfileService.DefaultWebServicePath, StringComparison.Ordinal))
                {
                    handlerType = typeof(ProfileService);
                }
                else
                if (url.EndsWith(AuthenticationService.DefaultWebServicePath, StringComparison.Ordinal))
                {
                    handlerType = typeof(AuthenticationService);
                }
                else
                {
                    handlerType = BuildManager.GetCompiledType(url);
                    if (handlerType == null)
                    {
                        handlerType = WebServiceParser.GetCompiledType(url, context);
                    }
                }

                return(RestHandler.GetHandler(context, handlerType, url));
            }
            if (request.PathInfo.StartsWith("/js", StringComparison.OrdinalIgnoreCase))
            {
                return(new ClientProxyHandler(WebServiceParser.GetCompiledType(url, context), url));
            }

            return(_wsFactory.GetHandler(context, requestType, url, pathTranslated));
        }
        public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath)
        {
            this.DumpRequest(context);
            HttpRequest httpRequest = context.Request;

            this.ConfigureAppName(httpRequest);
            string str   = httpRequest.QueryString[null];
            bool   flag  = string.Compare(httpRequest.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase) == 0;
            bool   flag2 = System.IO.File.Exists(httpRequest.PhysicalPath);

            if ((flag && flag2) && (str == null))
            {
                return(this.WebServicesFactory.GetHandler(context, verb, url, filePath));
            }
            if (flag2)
            {
                Type     compiledType      = WebServiceParser.GetCompiledType(url, context);
                string   machineAndAppName = Dns.GetHostName() + httpRequest.ApplicationPath;
                string[] strArray          = httpRequest.PhysicalPath.Split(new char[] { '\\' });
                string   uri   = strArray[strArray.Length - 1];
                Type     type2 = (Type)s_registeredDynamicTypeTable[uri];
                if (type2 != compiledType)
                {
                    RegistrationHelper.RegisterType(machineAndAppName, compiledType, uri);
                    s_registeredDynamicTypeTable[uri] = compiledType;
                }
            }
            return(new HttpRemotingHandler());
        }
Example #4
0
        public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string virtualPath, string path)
        {
            if (context.Request.PathInfo == "/js")
            {
                Type type = WebServiceParser.GetCompiledType(path, context);

                return(new JSProxyGenerator(type, virtualPath));
            }
            else
            {
                return(fallback.GetHandler(context, requestType, virtualPath, path));
            }
        }
Example #5
0
 /// <include file='doc\WebServiceHandlerFactory.uex' path='docs/doc[@for="WebServiceHandlerFactory.GetHandler"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath)
 {
     new AspNetHostingPermission(AspNetHostingPermissionLevel.Minimal).Demand();
     //if (CompModSwitches.Remote.TraceVerbose) DumpRequest(context);
     //System.Diagnostics.Debugger.Break();
     #if DEBUG
     if (CompModSwitches.Remote.TraceVerbose)
     {
         DumpRequest(context);
     }
     #endif
     Type type = WebServiceParser.GetCompiledType(filePath, context);
     return(CoreGetHandler(type, context, context.Request, context.Response));
 }
        public void GetMessagesForOperation()
        {
            #region væntigögn ...
            string TEST_DATA_FILE = Path.Combine(TEST_DATA_BASE_FOLDER, this.GetType().Namespace, this.GetType().Name, MethodBase.GetCurrentMethod().Name, EXPECTED_FILE_NAME);
            List <Pair <Pair <string, string>, Pair <string, string> > > test_data = TestUtilities.ReadObjectFromFile <List <Pair <Pair <string, string>, Pair <string, string> > > >(TEST_DATA_FILE);
            #endregion

            foreach (Pair <Pair <string, string>, Pair <string, string> > operation_and_expected_messages in test_data)
            {
                #region inntak tíundað ...
                TestUtilities.ReportObject <Pair <string, string> >(String.Format("Inntak {0}", MethodBase.GetCurrentMethod().Name), operation_and_expected_messages.First);
                #endregion

                Tuple <string, string> messages = WebServiceParser.GetMessages(operation_and_expected_messages.First.First, operation_and_expected_messages.First.Second);

                #region úttak lítillega meðhöndlað ...
                Pair <string, string> actual = new Pair <string, string>(messages.Item1, messages.Item2);
                #endregion

                #region úttak tíundað ...
                TestUtilities.ReportObject <Pair <string, string> >(String.Format("Úttak {0}", MethodBase.GetCurrentMethod().Name), actual);
                #endregion

                #region samanburður vænti- og raungagna ...
                Assert.IsTrue(operation_and_expected_messages.Second.Equals(actual));
                #endregion
            }

            //List<Pair<Pair<string, string>, Pair<string, string>>> test_data = new List<Pair<Pair<string, string>, Pair<string, string>>>();
            //Pair<string, string> input = new Pair<string, string>(@"TestData\ServiceDefinitions\RB.Torg.B2BBatchPayments\B2BBatchPayments.wsdl", "AddPayments");

            //Tuple<string, string> messages = WebServiceParser.GetMessages(input.First, input.Second);

            //test_data.Add(new Pair<Pair<string, string>, Pair<string, string>>(input, new Pair<string,string>(messages.Item1, messages.Item2)));

            //input = new Pair<string, string>(@"TestData\ServiceDefinitions\RB.Torg.B2BAccounts\B2BAccounts.wsdl", "GetAccounts");

            //messages = WebServiceParser.GetMessages(input.First, input.Second);

            //test_data.Add(new Pair<Pair<string, string>, Pair<string, string>>(input, new Pair<string,string>(messages.Item1, messages.Item2)));

            //TestUtilities.WriteObjectToFile<List<Pair<Pair<string, string>, Pair<string, string>>>>(test_data, TEST_DATA_FILE);
        }
        public void GetMessages()
        {
            #region væntigögn ...
            string TEST_DATA_FILE = Path.Combine(TEST_DATA_BASE_FOLDER, this.GetType().Namespace, this.GetType().Name, MethodBase.GetCurrentMethod().Name, EXPECTED_FILE_NAME);
            List <Pair <string, List <string> > > test_data = TestUtilities.ReadObjectFromFile <List <Pair <string, List <string> > > >(TEST_DATA_FILE);
            #endregion

            foreach (Pair <string, List <string> > wsdl_and_expected_operations in test_data)
            {
                #region inntak tíundað ...
                TestUtilities.ReportObject <string>(String.Format("Inntak {0}", MethodBase.GetCurrentMethod().Name), wsdl_and_expected_operations.First);
                #endregion

                List <string> messages = WebServiceParser.GetMessages(wsdl_and_expected_operations.First);

                #region úttak tíundað ...
                TestUtilities.ReportObject <List <string> >(String.Format("Úttak {0}", MethodBase.GetCurrentMethod().Name), messages);
                #endregion

                CollectionAssert.AreEqual(wsdl_and_expected_operations.Second, messages);
            }
        }
        public void GetOperationsWithMessages()
        {
            #region væntigögn ...
            string TEST_DATA_FILE = Path.Combine(TEST_DATA_BASE_FOLDER, this.GetType().Namespace, this.GetType().Name, MethodBase.GetCurrentMethod().Name, EXPECTED_FILE_NAME);
            List <Pair <string, List <Triple <string, string, string> > > > test_data = TestUtilities.ReadObjectFromFile <List <Pair <string, List <Triple <string, string, string> > > > >(TEST_DATA_FILE);
            #endregion

            foreach (Pair <string, List <Triple <string, string, string> > > wsdl_and_expected_operations in test_data)
            {
                #region inntak tíundað ...
                TestUtilities.ReportObject <string>(String.Format("Inntak {0}", MethodBase.GetCurrentMethod().Name), wsdl_and_expected_operations.First);
                #endregion

                List <Tuple <string, string, string> > operations = WebServiceParser.GetOperationsWithMessages(wsdl_and_expected_operations.First);

                #region úttak lítillega meðhöndlað ...
                List <Triple <string, string, string> > actual = new List <Triple <string, string, string> >();
                foreach (Tuple <string, string, string> operation in operations)
                {
                    actual.Add(new Triple <string, string, string>(operation.Item1, operation.Item2, operation.Item3));
                }
                #endregion

                #region úttak tíundað ...
                TestUtilities.ReportObject <List <Triple <string, string, string> > >(String.Format("Úttak {0}", MethodBase.GetCurrentMethod().Name), actual);
                #endregion

                #region samanburður vænti- og raungagna ...
                Assert.IsTrue(wsdl_and_expected_operations.Second.Count == actual.Count);

                for (int i = 0; i < wsdl_and_expected_operations.Second.Count; i++)
                {
                    Assert.IsTrue(wsdl_and_expected_operations.Second.ElementAt(i).Equals(actual.ElementAt(i)));
                }
                #endregion
            }
        }
        public void GetPortTypeName()
        {
            #region væntigögn ...
            string TEST_DATA_FILE = Path.Combine(TEST_DATA_BASE_FOLDER, this.GetType().Namespace, this.GetType().Name, MethodBase.GetCurrentMethod().Name, EXPECTED_FILE_NAME);
            List <Pair <string, string> > test_data = TestUtilities.ReadObjectFromFile <List <Pair <string, string> > >(TEST_DATA_FILE);
            #endregion

            foreach (Pair <string, string> datum in test_data)
            {
                #region greinagerð inntaks ...
                TestUtilities.ReportObject <string>(String.Format("Inntak {0}", MethodBase.GetCurrentMethod().Name), datum.First);
                #endregion

                string port_type_name = WebServiceParser.GetPortTypeName(datum.First);

                #region greinagerð úttaks ...
                TestUtilities.ReportObject <string>(String.Format("Úttak {0}", MethodBase.GetCurrentMethod().Name), port_type_name);
                #endregion

                Assert.AreEqual(port_type_name, datum.Second);
            }

            TestUtilities.WriteObjectToFile <List <Pair <string, string> > >(test_data, TEST_DATA_FILE);
        }
        public void GetServiceName()
        {
            #region væntigögn ...
            string TEST_DATA_FILE = Path.Combine(TEST_DATA_BASE_FOLDER, this.GetType().Namespace, this.GetType().Name, MethodBase.GetCurrentMethod().Name, EXPECTED_FILE_NAME);
            List <Pair <string, string> > test_data = TestUtilities.ReadObjectFromFile <List <Pair <string, string> > >(TEST_DATA_FILE);
            #endregion

            foreach (Pair <string, string> wsdl_and_expected_service_names in test_data)
            {
                #region inntak tíundað ...
                TestUtilities.ReportObject <string>(String.Format("Inntak {0}", MethodBase.GetCurrentMethod().Name), wsdl_and_expected_service_names.First);
                #endregion

                string service_name = WebServiceParser.GetServiceName(wsdl_and_expected_service_names.First);

                #region úttak tíundað ...
                TestUtilities.ReportObject <string>(String.Format("Úttak {0}", MethodBase.GetCurrentMethod().Name), service_name);
                #endregion

                #region samanburður vænti- og raungagna ...
                Assert.IsTrue(wsdl_and_expected_service_names.Second.Equals(service_name));
                #endregion
            }
        }
        } // ConfigureAppName

        public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath)
        {
            // REMACT:
            // If this is a request to the root vdir, we will route it to the activation
            //   handler instead.
            //if (context.Request.ApplicationPath.Equals("/"))
            //{
            //    if (s_remActType == null)
            //        s_remActType = Type.GetType("System.Runtime.Remoting.Channels.Http.RemotingActivationHandler, System.Runtime.Remoting.Activation");
            //
            //    if (s_remActType != null)
            //        return (IHttpHandler)Activator.CreateInstance(s_remActType);
            //}

            //if (CompModSwitches.Remote.TraceVerbose) DumpRequest(context);
            //System.Diagnostics.Debugger.Break();

            InternalRemotingServices.DebugOutChnl("HttpRemotingHandlderFactory::GetHanlder: IN");

            DumpRequest(context);  //

            HttpRequest httpRequest = context.Request;

            ConfigureAppName(httpRequest);

            string queryString = httpRequest.QueryString[null];

            bool bVerbIsGET  = (String.Compare(httpRequest.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase) == 0);
            bool bFileExists = File.Exists(httpRequest.PhysicalPath);

            if (bVerbIsGET && bFileExists && queryString == null)
            {
                InternalRemotingServices.DebugOutChnl("HttpRemotingHandlderFactory::GetHanlder: non-post -- send to WebServices");
                return(WebServicesFactory.GetHandler(context, verb, url, filePath));
            }
            else
            {
                InternalRemotingServices.DebugOutChnl("HttpRemotingHandlderFactory::GetHandler: post -- handling with Remoting");

                if (bFileExists)
                {
                    Type type = WebServiceParser.GetCompiledType(
                        url, context);

                    String machineAndAppName = Dns.GetHostName() + httpRequest.ApplicationPath;

                    // determine last part of url
                    String[] urlComponents = httpRequest.PhysicalPath.Split(new char[] { '\\' });
                    String   uri           = urlComponents[urlComponents.Length - 1];

                    // register the type if it has changed or hasn't been registered yet.
                    Type lastType = (Type)s_registeredDynamicTypeTable[uri];
                    if (lastType != type)
                    {
                        RegistrationHelper.RegisterType(machineAndAppName, type, uri);
                        s_registeredDynamicTypeTable[uri] = type;
                    }

                    return(new HttpRemotingHandler());
                }
                else
                {
                    return(new HttpRemotingHandler());
                }
            }
        }
Example #12
0
 private Type GetCompiledType(string url, HttpContext context)
 {
     return(WebServiceParser.GetCompiledType(url, context));
 }
Example #13
0
        private void tb_wsdl_changed(object sender, EventArgs e)
        {
            Tuple <string, string, string> schema_files = null;

            try
            {
                schema_files = WebServiceParser.GetSchemaFiles(tb_wsdl.Text);
            }
            catch
            { }

            if (schema_files != null)
            {
                if (!String.IsNullOrWhiteSpace(schema_files.Item1))
                {
                    tb_message_schema.Text = schema_files.Item1;
                }

                if (!String.IsNullOrWhiteSpace(schema_files.Item2))
                {
                    tb_type_schema.Text = schema_files.Item2;
                }

                if (!String.IsNullOrWhiteSpace(schema_files.Item3))
                {
                    tb_common_type_schema.Text = schema_files.Item3;
                }
            }

            List <Tuple <string, string, string> > operations = new List <Tuple <string, string, string> >();

            try
            {
                operations = WebServiceParser.GetOperationsWithMessages(tb_wsdl.Text);
            }
            catch
            { }

            cb_operation.Items.Clear();

            if (operations.Count == 0)
            {
                cb_operation.Items.Add("Engar þjónustuaðgerðir finnast ...");

                cb_operation.SelectedIndex = 0;

                b_generate_wikicode.Enabled = false;

                return;
            }

            operations.Sort();

            foreach (Tuple <string, string, string> operation in operations)
            {
                cb_operation.Items.Add(operation.Item1);
            }

            cb_operation.SelectedIndex = 0;

            b_generate_wikicode.Enabled = true;
        }
Example #14
0
        private void b_generate_wikicode_click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                string wikicode = Generator.GenerateWikiCode(
                    tb_description.Text,
                    cb_operation.SelectedItem.ToString(),
                    tb_wsdl.Text,
                    String.IsNullOrWhiteSpace(tb_message_schema.Text) ? tb_wsdl.Text : tb_message_schema.Text,
                    tb_type_schema.Text,
                    tb_common_type_schema.Text,
                    tb_version_number.Text,
                    dp_version_date.Text,
                    tb_version_description.Text,
                    cb_example.Checked,
                    cb_version.Checked,
                    cb_dictionary.Checked,
                    languages[cb_language.SelectedItem.ToString()]);

                this.Enabled = false;

                if (cb_wiki.CheckState == CheckState.Checked)
                {
                    string url = Generator.SubmitToWiki(
                        WebServiceParser.GetServiceName(tb_wsdl.Text),
                        cb_operation.SelectedItem.ToString(),
                        wikicode,
                        tb_wiki_user.Text,
                        tb_wiki_password.Text,
                        !cb_merge.Checked);

                    WikiInformation wiki_information = new WikiInformation(this, url);
                    wiki_information.Show();
                }
                else
                {
                    WikiCode wiki_information = new WikiCode(this, wikicode);
                    wiki_information.Show();
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(
                    String.Format(
                        @"Eftirfarandi villa kom upp: {0} {3} {3}Köllunarstakkur villu: {3}{1} {2}",
                        x.Message,
                        x.StackTrace,
                        x.InnerException == null ?
                        String.Empty :
                        String.Format("{1} {1}Innri villa: {1}{0} ",
                                      x.InnerException.Message,
                                      System.Environment.NewLine),
                        System.Environment.NewLine),
                    "Villa",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

                this.Enabled = true;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #15
0
        /// <summary>
        /// Retrieves instance of the page from Spring web application context.
        /// </summary>
        /// <param name="context">current HttpContext</param>
        /// <param name="requestType">type of HTTP request (GET, POST, etc.)</param>
        /// <param name="url">requested page URL</param>
        /// <param name="path">translated server path for the page</param>
        /// <returns>instance of the configured page object</returns>
        IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string url, string path)
        {
            new AspNetHostingPermission(AspNetHostingPermissionLevel.Minimal).Demand();

            IConfigurableApplicationContext appContext =
                WebApplicationContext.GetContext(url) as IConfigurableApplicationContext;

            if (appContext == null)
            {
                throw new InvalidOperationException(
                          "Implementations of IApplicationContext must also implement IConfigurableApplicationContext");
            }

            string appRelativeVirtualPath = WebUtils.GetAppRelativePath(url);

            AbstractHandlerFactory.NamedObjectDefinition nod =
                AbstractHandlerFactory.FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory);

            Type serviceType = null;

            if (nod != null)
            {
#if !MONO
                if (appContext.IsTypeMatch(nod.Name, typeof(WebServiceExporter)))
                {
                    WebServiceExporter wse = (WebServiceExporter)appContext.GetObject(nod.Name);
                    serviceType = wse.GetExportedType();
                }
                else
                {
                    serviceType = appContext.GetType(nod.Name);
                    // check if the type defines a Web Service
                    object[] wsAttribute = serviceType.GetCustomAttributes(typeof(WebServiceAttribute), true);
                    if (wsAttribute.Length == 0)
                    {
                        serviceType = null;
                    }
                }
#else
                serviceType = appContext.GetType(nod.Name);

                // check if the type defines a Web Service
                object[] wsAttribute = serviceType.GetCustomAttributes(typeof(WebServiceAttribute), true);
                if (wsAttribute.Length == 0)
                {
                    serviceType = null;
                }
#endif
            }

            if (serviceType == null)
            {
                serviceType = WebServiceParser.GetCompiledType(url, context);
            }


#if !MONO_2_0
            return((IHttpHandler)CoreGetHandler.Invoke(this, new object[] { serviceType, context, context.Request, context.Response }));
#else
            // find if the BuildManager already contains a cached value of the service type
            var buildCacheField = typeof(BuildManager).GetField("buildCache", BindingFlags.Static | BindingFlags.NonPublic);
            var buildCache      = (IDictionary)buildCacheField.GetValue(null);

            if (!buildCache.Contains(appRelativeVirtualPath))
            {
                // create new fake BuildManagerCacheItem wich represent the target type
                var buildManagerCacheItemType = Type.GetType("System.Web.Compilation.BuildManagerCacheItem, System.Web");
                var cacheItemCtor             = buildManagerCacheItemType.GetConstructor(new Type[] { typeof(Assembly), typeof(BuildProvider), typeof(CompilerResults) });
                var buildProvider             = new FakeBuildProvider(serviceType);
                var cacheItem = cacheItemCtor.Invoke(new object[] { serviceType.Assembly, buildProvider, null });

                // store it in the BuildManager
                buildCache [appRelativeVirtualPath] = cacheItem;
            }

            // now that the target type is in the cache, let the default process continue
            return(base.GetHandler(context, requestType, url, path));
#endif
        }
        public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath)
        {
#if TARGET_J2EE
            string fp = url;
#else
            string fp = filePath != null?filePath.Replace(HttpRuntime.AppDomainAppPath, "/").Replace(Path.DirectorySeparatorChar, '/') : null;
#endif

            Type type;
#if NET_2_0 && !TARGET_JVM
            type = BuildManager.GetCompiledType(url);
#else
            type = WebServiceParser.GetCompiledType(fp, context);
#endif

            WSProtocol protocol = GuessProtocol(context, verb);
#if NET_2_0
            context.Items ["WebServiceSoapVersion"] =
                protocol == WSProtocol.HttpSoap12 ?
                SoapProtocolVersion.Soap12 :
                SoapProtocolVersion.Default;
#endif
            bool         supported = false;
            IHttpHandler handler   = null;

            supported = WSConfig.IsSupported(protocol);
            if (!supported)
            {
                switch (protocol)
                {
#if NET_2_0
                default:
                    if (((protocol & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) &&
                        (WSConfig.Current.EnabledProtocols & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown)
                    {
                        throw new InvalidOperationException("Possible SOAP version mismatch.");
                    }
                    break;
#endif
                case WSProtocol.HttpPost:
                    if (WSConfig.IsSupported(WSProtocol.HttpPostLocalhost))
                    {
#if NET_2_0
                        supported = context.Request.IsLocal;
#else
                        string localAddr = context.Request.ServerVariables ["LOCAL_ADDR"];

                        supported = localAddr != null &&
                                    (localAddr == context.Request.ServerVariables ["REMOTE_ADDR"] ||
                                     IPAddress.IsLoopback(IPAddress.Parse(localAddr)));
#endif
                    }
                    break;
                }
            }
            if (!supported)
            {
                throw new InvalidOperationException("Unsupported request format.");
            }

            switch (protocol)
            {
            case WSProtocol.HttpSoap12:
            case WSProtocol.HttpSoap:
                handler = GetTypeHandler(context, new HttpSoapWebServiceHandler(type));
                break;

            case WSProtocol.HttpPost:
            case WSProtocol.HttpGet:
                handler = GetTypeHandler(context, new HttpSimpleWebServiceHandler(type, protocol.ToString()));
                break;

            case WSProtocol.Documentation:
                SoapDocumentationHandler soapHandler;
                soapHandler = new SoapDocumentationHandler(type, context);
                if (soapHandler.PageHandler is IRequiresSessionState)
                {
                    if (soapHandler.PageHandler is IReadOnlySessionState)
                    {
                        handler = new ReadOnlySessionWrapperHandler(soapHandler);
                    }
                    else
                    {
                        handler = new SessionWrapperHandler(soapHandler);
                    }
                }
                else
                {
                    handler = soapHandler;
                }
                break;
            }

            return(handler);
        }
Example #17
0
        static void Main(string[] args)
        {
            Console.Clear();

            Console.Out.WriteLine(String.Format("--- RB Wiki-kóðasmiður ({0}) ---------------------------------------------",
                                                Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            Console.Out.WriteLine();

            if (args == null || args.Length == 0)
            {
                args = new string[] { "-?" }
            }
            ;

            Arguments arguments = new Arguments(args);

            #region hjálp ...
            if (!(arguments["?"] == null && arguments["help"] == null))
            {
                Console.Out.WriteLine(@"Notkun: wikicodegenerator.exe");
                Console.Out.WriteLine("           -operation \"[nafn aðgerðar]\"");
                Console.Out.WriteLine("           -description \"[lýsing aðgerðar]\"");
                Console.Out.WriteLine("           -wsdl \"[slóð WSDL-skjals Torg-þjónustu]\"");
                Console.Out.WriteLine("          (-messages \"[slóð skemaskráar sem skilgreinir aðgerðir");
                Console.Out.WriteLine("              Torg-þjónustu]\")");
                Console.Out.WriteLine("          (-schema \"[slóð skemaskráar sem skilgreinir týpur Torg-þjónustu])\"");
                Console.Out.WriteLine("          (-common_schema \"[slóð skemaskráar sem skilgreinir samnýttar týpur");
                Console.Out.WriteLine("              Torg-þjónustu]\")");
                Console.Out.WriteLine("          (-example)");
                Console.Out.WriteLine("          (-version \"[útgáfunúmer]\"");
                Console.Out.WriteLine("           -version_date \"[útgáfudagsetning]\"");
                Console.Out.WriteLine("           -version_description \"[útgáfulýsing]\")");
                Console.Out.WriteLine("          (-dictionary)");
                Console.Out.WriteLine("          [-output \"[nafn úttaksskráar]\"");
                Console.Out.WriteLine("          |-wiki");
                Console.Out.WriteLine("          (-overwrite)");
                Console.Out.WriteLine("          (-user \"[Wiki-notandanafn]\"");
                Console.Out.WriteLine("           -password \"[Wiki-lykilorð]\")]");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"Tilgangur viðfanga:");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -operation: Tilgreinir nafn aðgerðar (sem skal smíða Wiki-kóða fyrir).");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -description: Tilgreinir lýsingu aðgerðar.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -wsdl: Tilgreinir slóð WSDL-skjals Torg-þjónustu.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -messages: Tilgreinir slóð skemaskráar sem skilgreinir aðgerðir");
                Console.Out.WriteLine(@"     Torg-þjónustu. Fyrir eldri Torg-þjónustur eru aðgerðir skilgreindar í");
                Console.Out.WriteLine(@"     WSDL-skjali þeirra og fyrir slíkar þjónustur þarf því ekki að tiltaka");
                Console.Out.WriteLine(@"     þetta viðfang.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -schema: Tilgreinir slóð skemaskráar sem skilgreinir týpur Torg-þjónustu.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -common_schema: Tilgreinir slóð skemaskráar sem skilgreinir samnýttar týpur");
                Console.Out.WriteLine(@"     Torg-þjónustu.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -example: Tilgreinir hvort smíða skuli XML-dæmi SOAP-skilaboða. Ef og");
                Console.Out.WriteLine(@"     aðeins ef viðfangið er tiltekið er XML-dæmi smíðuð.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -version: Tilgreinir útgáfunúmer Torg-þjónustu. Ef og aðeins ef");
                Console.Out.WriteLine(@"     viðfangið er tiltekið eru útgáfuupplýsingar settar í Wiki-kóða.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -version_date: Tilgreinir útgáfudagsetning Torg-þjónustu. Ef og aðeins ef");
                Console.Out.WriteLine(@"     viðfangið er tiltekið eru útgáfuupplýsingar settar í Wiki-kóða.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -version_description: Tilgreinir útgáflýsingu Torg-þjónustu. Ef og aðeins");
                Console.Out.WriteLine(@"     er viðfangið er tiltekið eru útgáfuupplýsingar settar í Wiki-kóða.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -dictionary: Tilgreinir hvort veita skuli upplýsingar um stöðu hugataka");
                Console.Out.WriteLine(@"     viðkomandi Torg-þjónsutu í Orðabók RB. Ef og aðeins ef viðfangið er");
                Console.Out.WriteLine(@"     tiltekið er staða viðkomandi hugtaka auglýst.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -output: Tilgreinir slóð úttaksskráar.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -wiki: Tilgreinir hvort uppfæra skuli viðeigandi Wiki-skjal með");
                Console.Out.WriteLine(@"     smíðuðum Wiki-kóða. Ef og aðeins ef viðfangið er tiltekið er reynt.");
                Console.Out.WriteLine(@"     uppfæra Wiki.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -overwrite: Tilgreinir hvort yfirskrifa skuli núverandi Wiki-skjal.");
                Console.Out.WriteLine(@"     Að öðrum kosti er reynt að flétta Wiki-kóða saman við Wiki-skjalið.");
                Console.Out.WriteLine(@"     Ef og aðeins ef viðfangið er tiltekið er Wiki-skjal yfirskrifað.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -user: Tilgreinir Wiki-notandanafn.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -password: Tilgreinir Wiki-lykilorð.");
                Console.Out.WriteLine();
                Console.Out.WriteLine(@"  -?|-help: Birtir þessar upplýsingar.");
                Console.Out.WriteLine();

                Console.In.Read();

                return;
            }
            #endregion

            if (ValidateInput(arguments))
            {
                try
                {
                    Tuple <string, string, string> schema_files = WebServiceParser.GetSchemaFiles(arguments["wsdl"]);

                    string messages_schema = (arguments["messages"] == null && String.IsNullOrWhiteSpace(schema_files.Item1)) ?
                                             arguments["wsdl"] :
                                             (arguments["messages"] == null ?
                                              schema_files.Item1 :
                                              arguments["messages"]);

                    string wikicode = Generator.GenerateWikiCode(arguments["description"],
                                                                 arguments["operation"],
                                                                 arguments["wsdl"],
                                                                 messages_schema,
                                                                 (arguments["schema"] == null ? schema_files.Item2 : arguments["schema"]),
                                                                 (arguments["common_schema"] == null ? schema_files.Item3 : arguments["common_schema"]),
                                                                 (arguments["version"] == null) ? String.Empty : arguments["version"],
                                                                 (arguments["version_date"] == null) ? String.Empty : arguments["version_date"],
                                                                 (arguments["version_description"] == null) ? String.Empty : arguments["version_description"],
                                                                 (arguments["example"] != null) ? true : false,
                                                                 (arguments["version"] == null || arguments["version_date"] == null || arguments["version_description"] == null) ? false : true,
                                                                 (arguments["dictionary"] != null) ? true : false,
                                                                 WikiCodeLanguage.Icelandic);

                    if (arguments["output"] != null)
                    {
                        File.WriteAllText(arguments["output"], string.IsNullOrWhiteSpace(wikicode) ? String.Empty : wikicode);

                        Console.Out.WriteLine();
                        Console.Out.WriteLine();
                        Console.Out.WriteLine(String.Format("Wiki-kóði fyrir {0} hefur verið skrifaður í eftirfarandi skrá:", arguments["operation"]));
                        Console.Out.WriteLine(String.Format("   {0}", arguments["output"]));
                    }

                    if (arguments["wiki"] != null)
                    {
                        string url = Generator.SubmitToWiki(WebServiceParser.GetServiceName(arguments["wsdl"]),
                                                            arguments["operation"],
                                                            wikicode,
                                                            arguments["user"],
                                                            arguments["password"],
                                                            (arguments["overwrite"] != null) ? true : false);

                        Console.Out.WriteLine();
                        Console.Out.WriteLine("Eftirfarandi Wiki-skjal hefur verið uppfært:");
                        Console.Out.WriteLine(String.Format("   {0}", url));
                    }
                }
                catch (Exception x)
                {
                    Console.Out.WriteLine();
                    Console.Out.WriteLine(String.Format("Eftirfarandi villa kom upp: {0}", x.Message));
                    Console.Out.WriteLine();
                    Console.Out.WriteLine(String.Format("Köllunarstakkur villu: {0}{1}", Environment.NewLine, x.StackTrace));
                }
            }

            Console.Out.WriteLine();
            Console.Out.WriteLine();
            Console.Out.WriteLine("Keyrslu WikiCodeGenerator er lokið.");
            Console.Out.WriteLine();
            Console.Out.WriteLine("--------------------------------------------------------------------------------");
        }