Beispiel #1
0
        static void Main(string[] args)
        {
            //service uses Discovery...
            var services = FindServices();
            var address  = services.Endpoints[0].Address;
            var binding  = new BasicHttpBinding();

            Console.WriteLine("Found service at: {0}", address);

            //create ChannelFactory Client to found echoservice
            ChannelFactory <IEchoService> factory =
                new ChannelFactory <IEchoService>(binding, address);

            IEchoService instance = factory.CreateChannel();

            string message = null;

            do
            {
                Console.Write("Enter a message, or blank to exit: ");
                message = Console.ReadLine();
                Console.WriteLine(instance.Echo(message));
            } while (!string.IsNullOrEmpty(message));

            factory.Close();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // allow server certificate that doesn't match the host in the endpoint address
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(IgnoreSubjectNameMismatch);

            string uri = "https://" + Environment.MachineName + ":8443/TestService/BinaryEncoderOverHTTPS";

            if (args.Length > 0)
            {
                uri = args[0];
            }
            EndpointAddress address = new EndpointAddress(uri);
            NetHttpBinding  binding = new NetHttpBinding();
            ChannelFactory <IEchoService> factory = new ChannelFactory <IEchoService>(binding, address);

            factory.Open();
            IEchoService service = factory.CreateChannel();

            Console.WriteLine(service.Echo("'Test string passed for calling service using code'"));

            Console.WriteLine("called service successfully using binding in code");

            factory = new ChannelFactory <IEchoService>("EchoServer");
            factory.Open();
            service = factory.CreateChannel();

            Console.WriteLine(service.Echo("'Test string passed for calling service using code'"));
            Console.WriteLine("called service successfully using binding from config. Press enter to exit...");

            Console.ReadLine();
        }
Beispiel #3
0
        public void Soap11Wss10(X509Certificate2 cert)
        {
            var binding = new CustomBinding();

            binding.Elements.Add(new CustomSecurityBindingElement()
            {
                MessageSecurityVersion = SecurityVersion.WSSecurity10
            });
            binding.Elements.Add(new TextMessageEncodingBindingElement()
            {
                MessageVersion = MessageVersion.Soap11
            });
            binding.Elements.Add(new HttpsTransportBindingElement()
            {
                //BypassProxyOnLocal = false,
                //UseDefaultWebProxy = false,
                //ProxyAddress = new Uri("http://localhost:8866")
            });

            var ep = new EndpointAddress("https://localhost:8080/services/echo/soap11wss10");
            ChannelFactory <IEchoService> channelFactory = new ChannelFactory <IEchoService>(binding, ep);

            channelFactory.Credentials.ClientCertificate.Certificate = cert;

            IEchoService client = channelFactory.CreateChannel();

            String pong = client.Echo("boe");

            Assert.Equal("boe", pong);
        }
Beispiel #4
0
        public MainViewModel(IPackagesUIService packagesUiService, IEchoService echoService, INuGetConfigurationService nuGetConfigurationService,
                             INuGetFeedVerificationService feedVerificationService, IMessageService messageService, IPackagesUpdatesSearcherService packagesUpdatesSearcherService,
                             IPackageBatchService packageBatchService, IUIVisualizerService uiVisualizerService)
        {
            Argument.IsNotNull(() => packagesUiService);
            Argument.IsNotNull(() => echoService);
            Argument.IsNotNull(() => nuGetConfigurationService);
            Argument.IsNotNull(() => feedVerificationService);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => packageBatchService);
            Argument.IsNotNull(() => uiVisualizerService);

            _packagesUiService              = packagesUiService;
            _nuGetConfigurationService      = nuGetConfigurationService;
            _feedVerificationService        = feedVerificationService;
            _messageService                 = messageService;
            _packagesUpdatesSearcherService = packagesUpdatesSearcherService;
            _packageBatchService            = packageBatchService;
            _uiVisualizerService            = uiVisualizerService;

            Echo = echoService.GetPackageManagementEcho();

            AvailableUpdates = new ObservableCollection <IPackageDetails>();

            ShowExplorer      = new Command(OnShowExplorerExecute);
            AdddPackageSource = new TaskCommand(OnAdddPackageSourceExecute, OnAdddPackageSourceCanExecute);
            VerifyFeed        = new TaskCommand(OnVerifyFeedExecute, OnVerifyFeedCanExecute);
            CheckForUpdates   = new TaskCommand(OnCheckForUpdatesExecute);
            OpenUpdateWindow  = new TaskCommand(OnOpenUpdateWindowExecute, OnOpenUpdateWindowCanExecute);
            Settings          = new TaskCommand(OnSettingsExecute);
        }
        public void JAVAServiceSSLConversation()
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            SecurityToken bootstrapSecurityToken = BootstrapSecurityTokenGenerator.MakeBootstrapSecurityToken();

            Uri audience = new Uri("https://oiosaml.trifork.com:8082/poc-provider/GenevaProviderService");

            RequestSecurityToken rst = WSTrustClientFactory.MakeOnBehalfOfSTSRequestSecurityToken(bootstrapSecurityToken, clientCertifikat, audience, requestClaims);

            var token = STSConnection.GetIssuedToken(rst);

            IEchoService echoService = WebserviceproviderChannelFactory.CreateChannelWithIssuedToken <IEchoService>(token, clientCertifikat, serviceCertifikat, new EndpointAddress(new Uri("https://oiosaml.trifork.com:8082/poc-provider/GenevaProviderService")));

            var req = new echo();

            req.structureToEcho       = new Structure();
            req.structureToEcho.value = "kvlsjvsldk";
            req.Framework             = new LibertyFrameworkHeader();

            var reply = echoService.Echo(req);

            Assert.IsNotNull(reply.Framework);
            Assert.IsNotNull(reply.structureToEcho.value);
        }
        public MainViewModel(IPackagesUIService packagesUiService, IEchoService echoService, INuGetConfigurationService nuGetConfigurationService,
            INuGetFeedVerificationService feedVerificationService, IMessageService messageService, IPackagesUpdatesSearcherService packagesUpdatesSearcherService,
            IPackageBatchService packageBatchService, IUIVisualizerService uiVisualizerService)
        {
            Argument.IsNotNull(() => packagesUiService);
            Argument.IsNotNull(() => echoService);
            Argument.IsNotNull(() => nuGetConfigurationService);
            Argument.IsNotNull(() => feedVerificationService);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => packageBatchService);
            Argument.IsNotNull(() => uiVisualizerService);

            _packagesUiService = packagesUiService;
            _nuGetConfigurationService = nuGetConfigurationService;
            _feedVerificationService = feedVerificationService;
            _messageService = messageService;
            _packagesUpdatesSearcherService = packagesUpdatesSearcherService;
            _packageBatchService = packageBatchService;
            _uiVisualizerService = uiVisualizerService;

            Echo = echoService.GetPackageManagementEcho();

            AvailableUpdates = new ObservableCollection<IPackageDetails>();

            ShowExplorer = new Command(OnShowExplorerExecute);
            AdddPackageSource = new TaskCommand(OnAdddPackageSourceExecute, OnAdddPackageSourceCanExecute);
            VerifyFeed = new TaskCommand(OnVerifyFeedExecute, OnVerifyFeedCanExecute);
            CheckForUpdates = new TaskCommand(OnCheckForUpdatesExecute);
            OpenUpdateWindow = new TaskCommand(OnOpenUpdateWindowExecute, OnOpenUpdateWindowCanExecute);
            Settings = new TaskCommand(OnSettingsExecute);
        }
Beispiel #7
0
 public EchoController(
     ILogger <EchoController> logger,
     IEchoService echoService)
 {
     _logger      = logger;
     _echoService = echoService;
 }
Beispiel #8
0
 public GrpcEchoService(
     ILogger <GrpcEchoService> logger,
     IEchoService echoService)
 {
     _logger      = logger;
     _echoService = echoService;
 }
        private static void CallEcho()
        {
            Uri    baseAddr = new Uri("http://localhost:7000/DemoServices/SampleRoutingService");
            string message  = "Routing demo message";

            Console.WriteLine("Press [ENTER] to call SimpleEchoService");
            Console.ReadLine();

            using (ChannelFactory <IEchoService> factory = new ChannelFactory <IEchoService>(new BasicHttpBinding(),
                                                                                             new EndpointAddress(baseAddr)))
            {
                try
                {
                    IEchoService proxy = factory.CreateChannel();
                    Console.WriteLine($"Service response: {proxy.GetData(message)}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Exception: {ex.Message}");
                }

                Console.WriteLine("Press [ENTER] to close client");
                Console.ReadLine();
            }
        }
Beispiel #10
0
        public CatelLogListener(IDispatcherService dispatcherService, IEchoService echoService)
        {
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => echoService);

            _dispatcherService = dispatcherService;

            _echo = echoService.GetPackageManagementEcho();
        }
        public SimpleLogListener(INuGetLogListeningSevice nuGetLogListeningSevice,
            IEchoService echoService, IDispatcherService dispatcherService)
            : base( nuGetLogListeningSevice)
        {            
            Argument.IsNotNull(() => echoService);
            Argument.IsNotNull(() => dispatcherService);

            _dispatcherService = dispatcherService;

            _echo = echoService.GetPackageManagementEcho();
        }
Beispiel #12
0
        public SimpleLogListener(INuGetLogListeningSevice nuGetLogListeningSevice,
                                 IEchoService echoService, IDispatcherService dispatcherService)
            : base(nuGetLogListeningSevice)
        {
            Argument.IsNotNull(() => echoService);
            Argument.IsNotNull(() => dispatcherService);

            _dispatcherService = dispatcherService;

            _echo = echoService.GetPackageManagementEcho();
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            Console.WriteLine(
                "Press <enter> to open a channel and send a request.");

            Console.ReadLine();

            MessageHeader shareableInstanceContextHeader = MessageHeader.CreateHeader(
                CustomHeader.HeaderName,
                CustomHeader.HeaderNamespace,
                Guid.NewGuid().ToString());

            ChannelFactory <IEchoService> channelFactory =
                new ChannelFactory <IEchoService>("echoservice");

            IEchoService proxy = channelFactory.CreateChannel();


            using (new OperationContextScope((IClientChannel)proxy))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(shareableInstanceContextHeader);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Service returned: " + proxy.Echo("Apple"));
                Console.ForegroundColor = ConsoleColor.Gray;
            }

            ((IChannel)proxy).Close();

            Console.WriteLine("Channel No 1 closed.");

            Console.WriteLine(
                "Press <ENTER> to send another request from a different channel " +
                "to the same instance. ");

            Console.ReadLine();

            proxy = channelFactory.CreateChannel();

            using (new OperationContextScope((IClientChannel)proxy))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(shareableInstanceContextHeader);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Service returned: " + proxy.Echo("Apple"));
                Console.ForegroundColor = ConsoleColor.Gray;
            }

            ((IChannel)proxy).Close();

            Console.WriteLine("Channel No 2 closed.");

            Console.WriteLine("Press <ENTER> to complete test.");
            Console.ReadLine();
        }
Beispiel #14
0
        public void soap11Plain()
        {
            var binding = new BasicHttpsBinding();
            var ep      = new EndpointAddress("https://localhost:8080/services/echo/soap11");
            ChannelFactory <IEchoService> channelFactory = new ChannelFactory <IEchoService>(binding, ep);

            IEchoService client = channelFactory.CreateChannel();

            String pong = client.Echo("boe");

            Assert.Equal("boe", pong);
        }
Beispiel #15
0
        public void soap12Plain()
        {
            var binding = new WSHttpBinding(SecurityMode.Transport);
            var ep      = new EndpointAddress("https://localhost:8080/services/echo/soap12");
            ChannelFactory <IEchoService> channelFactory = new ChannelFactory <IEchoService>(binding, ep);

            IEchoService client = channelFactory.CreateChannel();

            String pong = client.Echo("boe");

            Assert.Equal("boe", pong);
        }
Beispiel #16
0
        /// <summary>
        /// Called by the framework when the user clicks the "apply" menu item or toolbar button.
        /// </summary>
        public void Apply()
        {
            try
            {
                _echoService = (IEchoService)Activator.GetObject(typeof(IEchoService), RemotingSettings.Default.RemoteHostUrl);

                this.Context.DesktopWindow.ShowMessageBox(_echoService.Echo("If you see this, remoting is working."),
                                                          MessageBoxActions.Ok);
            }
            catch (Exception e)
            {
                ExceptionHandler.Report(e, this.Context.DesktopWindow);
            }
        }
Beispiel #17
0
                static void Main(string[]  args)
                 {
                        Binding binding           =  new BasicHttpBinding();
                        EndpointAddress endpoint  =  new EndpointAddress(new Uri("http://localhost:5000/EchoService.svc"));
                        ChannelFactory <IEchoService>  channelFactory  =  new ChannelFactory <IEchoService>(binding,  endpoint);

                        IEchoService echoService  =  channelFactory.CreateChannel();

                        string echo  =  echoService.Echo("Bonjour DSED !");
                        try
                         {
                                echoService.CalculInteretAnnuel(-1,  0);
                            
            }
                        catch (Exception ex)
                         {
                                Console.Error.WriteLine(ex.Message);
                            
            }

                        int nombreEssais         =  0;
                        int nombreMaximumEssais  =  3;
                        bool appelEffectue       =  false;
                        decimal interet          =   - 1m;
                        while (!appelEffectue  &&  nombreEssais  <  nombreMaximumEssais)
                         {
                                ++ nombreEssais;
                                try
                                 {
                                        interet        =  echoService.CalculInteretAnnuel(100,   .199m);
                                        appelEffectue  =  true;
                                    
                }
                                catch (Exception)
                                 {
                                        if (nombreEssais  >=  nombreMaximumEssais)
                                         {
                                                throw;
                                            
                    }
                                    
                }
                            
            }
                    
        }
        static void Main(string[] args)
        {
            //In real implementation, use server IP instead of localhost
            ChannelFactory <IEchoService> factory = new ChannelFactory <IEchoService>(new BasicHttpBinding(), new EndpointAddress("http://localhost:8000/Echo"));
            IEchoService proxy            = factory.CreateChannel();
            int          processedSeccond = 0;

            while (true)
            {
                var dateTime = DateTime.Now;
                if (dateTime.Second % 10 == 0 && dateTime.Second != processedSeccond)
                {
                    processedSeccond = dateTime.Second;
                    string data = dateTime.ToString();    //or Console readLine for manual data entry
                    Console.WriteLine("Recieved Response: " + proxy.Echo(str));
                }
            }
        }
        public void MissingLibertyHeader()
        {
            SecurityToken bootstrapSecurityToken = BootstrapSecurityTokenGenerator.MakeBootstrapSecurityToken();

            Uri audience = new Uri("http://localhost/Echo/service.svc/Echo");

            RequestSecurityToken rst = WSTrustClientFactory.MakeOnBehalfOfSTSRequestSecurityToken(bootstrapSecurityToken, clientCertifikat, audience, requestClaims);

            var token = STSConnection.GetIssuedToken(rst);

            IEchoService echoService = WebserviceproviderChannelFactory.CreateChannelWithIssuedToken <IEchoService>(token, clientCertifikat, serviceCertifikat, new EndpointAddress(new Uri("http://lh-z3jyrnwtj9d7/EchoWebserviceProvider/service.svc/Echo"), new DnsEndpointIdentity(DnsIdentityForServiceCertificates)));

            var req = new echo();

            req.structureToEcho = new Structure();
            req.Framework       = null; //Failure

            echoService.Echo(req);
        }
Beispiel #20
0
        public void soap12Wss10Rsa()
        {
            var binding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);

            binding.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;
            binding.Security.Message.NegotiateServiceCredential = false;
            binding.Security.Message.EstablishSecurityContext   = false;

            var ep = new EndpointAddress("https://localhost:8080/services/echo/soap12wss10");
            ChannelFactory <IEchoService> channelFactory = new ChannelFactory <IEchoService>(binding, ep);

            channelFactory.Credentials.ClientCertificate.Certificate = rsa;

            IEchoService client = channelFactory.CreateChannel();

            String pong = client.Echo("boe");

            Assert.Equal("boe", pong);
        }
        static void MainEx(string[] args)
        {
            try
            {
                EndpointAddress ep = new EndpointAddress("http://localhost:8088/HelloIndigo/EchoService");

                IEchoService proxy
                    = ChannelFactory <IEchoService> .CreateChannel(new BasicHttpBinding(),
                                                                   ep);

                string s = null;
                proxy.Echo(out s, "Echo, me!");

                Console.WriteLine(string.Format("HelloIndigo.HelloIndigoService::Echo : {0}", s));
            }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.ToString());
            }
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            using (var factory = new ChannelFactory <IEchoService>("EchoService"))
            {
                IEchoService channel = null;

                try
                {
                    channel = factory.CreateChannel();
                    Console.WriteLine(channel.Echo("test"));
                    Console.WriteLine(channel.Echo(null));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.WriteLine($"Channel state: {((IClientChannel)channel).State}");
                }

                Console.WriteLine(channel.Echo("Still Active"));
                Console.ReadKey();
            }
        }
Beispiel #23
0
        public void federation()
        {
            //var stsEp = new EndpointAddress("https://services-int.ehealth.fgov.be/IAM/SingleSignOnService/v1");
            var stsEp = new EndpointAddress("https://localhost:8080/services/echo/soap12wss10");

            var stsBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);

            stsBinding.Security.Message.ClientCredentialType       = MessageCredentialType.Certificate;
            stsBinding.Security.Message.NegotiateServiceCredential = false;
            stsBinding.Security.Message.EstablishSecurityContext   = false;

            WSFederationHttpBinding binding;

#if NETFRAMEWORK
            binding = new WSFederationHttpBinding();
            binding.Security.Mode = WSFederationHttpSecurityMode.TransportWithMessageCredential;
            binding.Security.Message.IssuedKeyType   = SecurityKeyType.AsymmetricKey;
            binding.Security.Message.IssuerAddress   = stsEp;
            binding.Security.Message.IssuerBinding   = stsBinding;
            binding.Security.Message.IssuedTokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";

            ClaimTypeRequirement ctr = new ClaimTypeRequirement("http://example.org/claim/c1", false);
            binding.Security.Message.ClaimTypeRequirements.Add(ctr);
#else
            var parameters = WSTrustTokenParameters.CreateWSFederationTokenParameters(stsBinding, stsEp);
            parameters.KeyType   = SecurityKeyType.AsymmetricKey;
            parameters.TokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
            binding = new WSFederationHttpBinding(parameters);
#endif
            var ep = new EndpointAddress("https://localhost:8080/services/echo/soap12");
            ChannelFactory <IEchoService> channelFactory = new ChannelFactory <IEchoService>(binding, ep);
            channelFactory.Credentials.ClientCertificate.Certificate = rsa;

            IEchoService client = channelFactory.CreateChannel();

            String pong = client.Echo("boe");
            Assert.Equal("boe", pong);
        }
        public void DotNetServiceSSLConversation()
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            SecurityToken bootstrapSecurityToken = BootstrapSecurityTokenGenerator.MakeBootstrapSecurityToken();

            Uri audience = new Uri("http://localhost/Echo/service.svc/Echo");

            RequestSecurityToken rst = WSTrustClientFactory.MakeOnBehalfOfSTSRequestSecurityToken(bootstrapSecurityToken, clientCertifikat, audience, requestClaims);

            var token = STSConnection.GetIssuedToken(rst);

            IEchoService echoService = WebserviceproviderChannelFactory.CreateChannelWithIssuedToken <IEchoService>(token, clientCertifikat, serviceCertifikat, new EndpointAddress(new Uri("https://lh-z3jyrnwtj9d7/EchoWebserviceProvider/service.svc/Echo")));

            var req = new echo();

            req.structureToEcho = new Structure();
            req.Framework       = new LibertyFrameworkHeader();

            var reply = echoService.Echo(req);

            Assert.IsNotNull(reply.Framework);
        }
Beispiel #25
0
        static void InitProxyService()
        {
            var containerBuilder = new ContainerBuilder();
            var host             = new Jimu.Client.ApplicationClientBuilder(containerBuilder)
                                   //.UseLog4netLogger(new LogOptions { EnableConsoleLog = true })
                                   //.UsePollingAddressSelector()
                                   //.UseConsulForDiscovery(new Jimu.Client.Discovery.ConsulIntegration.ConsulOptions("127.0.0.1", 8500, "JimuService-"))
                                   //.UseDotNettyForTransfer()
                                   //.UseHttpForTransfer()
                                   //.UseServiceProxy(new Jimu.Client.Proxy.ServiceProxyOptions(new[] { "IServices" }))
                                   .Build()
            ;

            host.Run();
            var proxy = host.Container.Resolve <IServiceProxy>();

            _echoService = proxy.GetService <IEchoService>();
            Task.Run(() =>
            {
                Thread.Sleep(5000);
                var ret = _echoService.GetEcho("哈哈");
                Console.WriteLine("==== echo " + ret);
            });
        }
Beispiel #26
0
        static void Main()
        {
            // Create the custom binding and an endpoint address for the service.
            Binding         multipleTokensBinding        = BindingHelper.CreateMultiFactorAuthenticationBinding();
            EndpointAddress serviceAddress               = new EndpointAddress("http://localhost/servicemodelsamples/service.svc");
            ChannelFactory <IEchoService> channelFactory = null;
            IEchoService client = null;

            Console.WriteLine("Username authentication required.");
            Console.WriteLine("Provide a valid machine or domain account. [domain\\user]");
            Console.WriteLine("   Enter username:"******"   Enter password:"******"";
            ConsoleKeyInfo info     = Console.ReadKey(true);

            while (info.Key != ConsoleKey.Enter)
            {
                if (info.Key != ConsoleKey.Backspace)
                {
                    if (info.KeyChar != '\0')
                    {
                        password += info.KeyChar;
                    }
                    info = Console.ReadKey(true);
                }
                else if (info.Key == ConsoleKey.Backspace)
                {
                    if (password != "")
                    {
                        password = password.Substring(0, password.Length - 1);
                    }
                    info = Console.ReadKey(true);
                }
            }

            for (int i = 0; i < password.Length; i++)
            {
                Console.Write("*");
            }

            Console.WriteLine();

            try
            {
                // Create a proxy with the previously create binding and endpoint address
                channelFactory = new ChannelFactory <IEchoService>(multipleTokensBinding, serviceAddress);

                // configure the username credentials, the client certificate and the server certificate on the channel factory
                channelFactory.Credentials.UserName.UserName = username;
                channelFactory.Credentials.UserName.Password = password;

                channelFactory.Credentials.ClientCertificate.SetCertificate("CN=client.com", StoreLocation.CurrentUser, StoreName.My);
                channelFactory.Credentials.ServiceCertificate.SetDefaultCertificate("CN=localhost", StoreLocation.LocalMachine, StoreName.My);

                client = channelFactory.CreateChannel();

                Console.WriteLine("Echo service returned: {0}", client.Echo());

                ((IChannel)client).Close();
                channelFactory.Close();
            }
            catch (CommunicationException e)
            {
                Abort((IChannel)client, channelFactory);

                // if there is a fault then print it out
                FaultException fe  = null;
                Exception      tmp = e;
                while (tmp != null)
                {
                    fe = tmp as FaultException;
                    if (fe != null)
                    {
                        break;
                    }
                    tmp = tmp.InnerException;
                }
                if (fe != null)
                {
                    Console.WriteLine("The server sent back a fault: {0}", fe.CreateMessageFault().Reason.GetMatchingTranslation().Text);
                }
                else
                {
                    Console.WriteLine("The request failed with exception: {0}", e);
                }
            }
            catch (TimeoutException)
            {
                Abort((IChannel)client, channelFactory);
                Console.WriteLine("The request timed out");
            }
            catch (Exception e)
            {
                Abort((IChannel)client, channelFactory);
                Console.WriteLine("The request failed with unexpected exception: {0}", e);
            }

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
Beispiel #27
0
 public EchoWcfService(IEchoService service)
 {
     _service = service;
 }
Beispiel #28
0
 public BotController(IEchoService updateService, ILogger <BotController> logger)
 {
     _updateService = updateService;
     _logger        = logger;
 }
Beispiel #29
0
 public override Task SetupAsync(WorkloadContext context)
 {
     channel = GrpcChannel.ForAddress("http://localhost:5059");
     client  = MagicOnionClient.Create <IEchoService>(channel);
     return(base.SetupAsync(context));
 }
Beispiel #30
0
        static void Main()
        {
            string   creditCardNumber = "11111111";
            DateTime expirationTime   = new DateTime(2010, 12, 15, 0, 0, 0, 0, DateTimeKind.Utc);
            string   issuer           = Constants.TestCreditCardIssuer;
            ChannelFactory <IEchoService> channelFactory = null;
            IEchoService client = null;


            Console.WriteLine("Please enter your credit card information:");
            Console.WriteLine("Please enter a credit card number (hit [enter] to pick 11111111 - a valid number on file): ");
            string input = Console.ReadLine();

            if (input.Trim() != string.Empty)
            {
                creditCardNumber = input;
                bool readDate = false;
                while (!readDate)
                {
                    Console.WriteLine("Please enter the expiration time (yyyy/mm/dd): ");
                    input = Console.ReadLine().Trim();
                    try
                    {
                        expirationTime = DateTime.Parse(input, System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.AdjustToUniversal);
                        readDate       = true;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("You did not enter a valid date format. Please try again");
                    }
                }
                Console.WriteLine("Please enter the issuer of the credit card (hit enter to pick {0}", Constants.TestCreditCardIssuer);
                input = Console.ReadLine().Trim();
                if (input != string.Empty)
                {
                    issuer = input;
                }
            }
            try
            {
                Binding         creditCardBinding = BindingHelper.CreateCreditCardBinding();
                EndpointAddress serviceAddress    = new EndpointAddress("http://localhost/servicemodelsamples/service.svc");

                // Create a client with given client endpoint configuration
                channelFactory = new ChannelFactory <IEchoService>(creditCardBinding, serviceAddress);

                // configure the credit card credentials on the channel factory
                CreditCardClientCredentials credentials = new CreditCardClientCredentials(new CreditCardInfo(creditCardNumber, issuer, expirationTime));

                // configure the service certificate on the credentials
                credentials.ServiceCertificate.SetDefaultCertificate("CN=localhost", StoreLocation.LocalMachine, StoreName.My);

                // replace ClientCredentials with CreditCardClientCredentials
                channelFactory.Endpoint.Behaviors.Remove(typeof(ClientCredentials));
                channelFactory.Endpoint.Behaviors.Add(credentials);

                client = channelFactory.CreateChannel();

                Console.WriteLine("Echo service returned: {0}", client.Echo());

                ((IChannel)client).Close();
                channelFactory.Close();
            }
            catch (CommunicationException e)
            {
                Abort((IChannel)client, channelFactory);

                // if there is a fault then print it out
                FaultException fe  = null;
                Exception      tmp = e;
                while (tmp != null)
                {
                    fe = tmp as FaultException;
                    if (fe != null)
                    {
                        break;
                    }
                    tmp = tmp.InnerException;
                }
                if (fe != null)
                {
                    Console.WriteLine("The server sent back a fault: {0}", fe.CreateMessageFault().Reason.GetMatchingTranslation().Text);
                }
                else
                {
                    Console.WriteLine("The request failed with exception: {0}", e);
                }
            }
            catch (TimeoutException)
            {
                Abort((IChannel)client, channelFactory);
                Console.WriteLine("The request timed out");
            }
            catch (Exception e)
            {
                Abort((IChannel)client, channelFactory);
                Console.WriteLine("The request failed with unexpected exception: {0}", e);
            }

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
Beispiel #31
0
 public HomeController(IEchoService echoService)
 {
     _echoService = echoService;
 }
Beispiel #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EchoController"/> class.
 /// </summary>
 /// <param name="echoService">
 /// The echo service ( gets injected through Ninject ).
 /// </param>
 public EchoController(IEchoService echoService)
 {
     _echoService = echoService;
 }