コード例 #1
0
ファイル: EndToEndFixture.cs プロジェクト: 21robin12/wcfpad
        private dynamic InvokeMethod(object parameters, string methodName)
        {
            var parameterTypeFactory      = new ParameterTypeFactory();
            var endpointFactory           = new EndpointFactory(parameterTypeFactory);
            var pathHelper                = new PathHelper();
            var configHelper              = new ConfigHelper();
            var wcfClientBuilder          = new WcfClientBuilder(pathHelper);
            var endpointCache             = new EndpointCache(pathHelper);
            var endpointDefinitionFactory = new EndpointDefinitionFactory(pathHelper, wcfClientBuilder, configHelper);
            var analysisService           = new AnalysisService(endpointFactory, endpointDefinitionFactory, endpointCache);
            var invocationService         = new InvocationService(endpointCache, configHelper);

            var port    = 3030;
            var address = $"http://localhost:{port}/Services/DummyService.svc";

            IList <Endpoint> endpoints = null;

            try
            {
                endpoints = analysisService.AnalyzeAddress(address);
            }
            catch (Exception e)
            {
                throw new Exception($"Could not analyze service at address {address}. " +
                                    "This may be because the service is not running in IIS. To add the service " +
                                    "in IIS, add a new website with the following parameters: path=C:\\inetpub\\wwwroot, " +
                                    $"binding=http, port={port}, hostname=<blank>. Then right-click this website " +
                                    "and select Add Application, using the following parameters: alias=Services, " +
                                    "path=<path to WcfPad.DummyWcfService project>. You may also need to give the " +
                                    "users IIS_IUSRS and IUSR full access to the WcfPad.DummyWcfService folder. " +
                                    $"EXCEPTION MESSAGE: {e.Message}");
            }

            var     serializedParameters = JsonConvert.SerializeObject(parameters);
            dynamic response             = invocationService.InvokeMethod(endpoints.FirstOrDefault().Id, methodName, serializedParameters);

            return(response);
        }