Ejemplo n.º 1
0
        private void WCFServiceConnect()
        {
            ChannelFactory <IWCFContract> factory = new ChannelFactory <IWCFContract>();

            string address = "net.tcp://localhost:8080/myAddress";

            factory.Endpoint.Address = new EndpointAddress(address);

            factory.Endpoint.Binding = new NetTcpBinding();

            factory.Endpoint.Contract.ContractType = typeof(IWCFContract);

            channel = factory.CreateChannel();
        }
Ejemplo n.º 2
0
        public WCFClient(NetTcpBinding binding, EndpointAddress address)

        {
            proxy = new ChannelFactory <IWCFContract>(binding, address);
            /// cltCertCN.SubjectName should be set to the client's username. .NET WindowsIdentity class provides information about Windows user running the given process
            string cltCertCN = Manager.Formatter.ParseName(WindowsIdentity.GetCurrent().Name);

            proxy.Credentials.ServiceCertificate.Authentication.CertificateValidationMode  = System.ServiceModel.Security.X509CertificateValidationMode.Custom;
            proxy.Credentials.ServiceCertificate.Authentication.CustomCertificateValidator = new ClientCertValidator();
            proxy.Credentials.ServiceCertificate.Authentication.RevocationMode             = X509RevocationMode.NoCheck;

            /// Set appropriate client's certificate on the channel. Use CertManager class to obtain the certificate based on the "cltCertCN"
            proxy.Credentials.ClientCertificate.Certificate = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, "wcfclient");

            factory = proxy.CreateChannel();
        }
Ejemplo n.º 3
0
        public async Task <ISingleModelResponse <string> > Refresh(int instanceId)
        {
            ISingleModelResponse <string> result = new SingleModelResponse <string>();

            result.ErrorMessage = "OK";

            try
            {
                ChannelFactory <IWCFContract> mChannelFacory = new ChannelFactory <IWCFContract>(new NetTcpBinding(),
                                                                                                 new EndpointAddress(ENDPOINT));
                IWCFContract proxy = mChannelFacory.CreateChannel();

                proxy.RefreshInstance(instanceId);
            }
            catch (Exception e)
            {
                result.DidError     = true;
                result.ErrorMessage = e.Message;
            }


            return(result);
        }