当前位置: 首页>>代码示例>>C#>>正文


C# ServiceModel.EndpointAddress类代码示例

本文整理汇总了C#中System.ServiceModel.EndpointAddress的典型用法代码示例。如果您正苦于以下问题:C# EndpointAddress类的具体用法?C# EndpointAddress怎么用?C# EndpointAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EndpointAddress类属于System.ServiceModel命名空间,在下文中一共展示了EndpointAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main( string[] args )
        {
            EndpointAddress address =
               new EndpointAddress("http://localhost:8001/TradeService");
            WSHttpBinding binding = new WSHttpBinding();
            System.ServiceModel.ChannelFactory<ITradeService> cf =
                new ChannelFactory<ITradeService>(binding, address);
            ITradeService proxy = cf.CreateChannel();

            Console.WriteLine("\nTrade IBM");
            try
            {
                double result = proxy.TradeSecurity("IBM", 1000);
                Console.WriteLine("Cost was " + result);
                Console.WriteLine("\nTrade MSFT");
                result = proxy.TradeSecurity("MSFT", 2000);
                Console.WriteLine("Cost was " + result);
            }
            catch (Exception ex)
            {
                Console.Write("Can not perform task. Error Message - " + ex.Message);
            }
            Console.WriteLine("\n\nPress <enter> to exit...");
            Console.ReadLine();
        }
开发者ID:brian-smith723,项目名称:DesignPatterns,代码行数:25,代码来源:Program.cs

示例2: GetWcfReference

 public static Object GetWcfReference(Type type, object[] info)
 {
   if (info.Length == 2)
     info = new object[] { info[0], null, info[1] };
   if (info.Length != 3)
     return null;
   Type genType;
   Type factType;
   if (info[0] == null)
   {
     genType = typeof(ChannelFactory<>);
     factType = genType.MakeGenericType(new Type[] { type });
     if (info[1] == null)
       info[1] = new WSHttpBinding();
     info = new object[] { info[1], new EndpointAddress((string)info[2]) };
   }
   else
   {
     genType = typeof(DuplexChannelFactory<>);
     factType = genType.MakeGenericType(new Type[] { type });
     info[0] = new InstanceContext(info[0]);
     info[2] = new EndpointAddress((string)info[2]);
     if (info[1] == null)
       info[1] = new WSDualHttpBinding();
   }
   object factObject = Activator.CreateInstance(factType, info);
   MethodInfo methodInfo = factType.GetMethod("CreateChannel", new Type[] { });
   return methodInfo.Invoke(factObject, null);
 }
开发者ID:Logeshkumar,项目名称:Projects,代码行数:29,代码来源:ServiceRefCreator.cs

示例3: SameBinding_Binary_EchoComplexString

    public static void SameBinding_Binary_EchoComplexString()
    {
        CustomBinding binding = null;
        ChannelFactory<IWcfService> factory = null;
        EndpointAddress endpointAddress = null;
        IWcfService serviceProxy = null;
        ComplexCompositeType compositeObject = null;
        ComplexCompositeType result = null;

        try
        {
            // *** SETUP *** \\
            binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement());
            endpointAddress = new EndpointAddress(Endpoints.HttpBinary_Address);
            factory = new ChannelFactory<IWcfService>(binding, endpointAddress);
            serviceProxy = factory.CreateChannel();
            compositeObject = ScenarioTestHelpers.GetInitializedComplexCompositeType();

            // *** EXECUTE *** \\
            result = serviceProxy.EchoComplex(compositeObject);

            // *** VALIDATE *** \\
            Assert.True(compositeObject.Equals(result), String.Format("    Error: expected response from service: '{0}' Actual was: '{1}'", compositeObject, result));

            // *** CLEANUP *** \\
            factory.Close();
            ((ICommunicationObject)serviceProxy).Close();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
        }
    }
开发者ID:roncain,项目名称:wcf,代码行数:34,代码来源:BinaryEncodingTests.4.0.0.cs

示例4: Main

        static void Main(string[] args)
        {
            Console.Title = "CLIENT";

            // Указание, где ожидать входящие сообщения.
            Uri address = new Uri("http://localhost:4000/IContract");

            // Указание, как обмениваться сообщениями.
            BasicHttpBinding binding = new BasicHttpBinding();

            // Создание Конечной Точки. 
            EndpointAddress endpoint = new EndpointAddress(address);

            // Создание фабрики каналов.
            ChannelFactory<IContract> factory = new ChannelFactory<IContract>(binding, endpoint);

            // Использование factory для создания канала (прокси).
            IContract channel = factory.CreateChannel();
            
            // Использование канала для отправки сообщения получателю и приема ответа.
            string response = channel.Say("Hello WCF!");

            Console.WriteLine(response);

            // Задержка.
            Console.ReadKey();
        }
开发者ID:novakvova,项目名称:WCFLesson1,代码行数:27,代码来源:Client.cs

示例5: ProtoBufMetaDataReplyChannel

 public ProtoBufMetaDataReplyChannel(EndpointAddress address,
                                     ChannelManagerBase parent, IReplyChannel innerChannel) :
     base(parent, innerChannel)
 {
     this._localAddress = address;
     _innerChannel = innerChannel;
 }
开发者ID:yonglehou,项目名称:ProtoBuf.Wcf,代码行数:7,代码来源:ProtoBufMetaDataReplyChannel.cs

示例6: SslStreamSecurityUpgradeInitiator

 public SslStreamSecurityUpgradeInitiator(SslStreamSecurityUpgradeProvider parent, EndpointAddress remoteAddress, Uri via) : base("application/ssl-tls", remoteAddress, via)
 {
     SecurityTokenResolver resolver;
     this.parent = parent;
     InitiatorServiceModelSecurityTokenRequirement tokenRequirement = new InitiatorServiceModelSecurityTokenRequirement {
         TokenType = SecurityTokenTypes.X509Certificate,
         RequireCryptographicToken = true,
         KeyUsage = SecurityKeyUsage.Exchange,
         TargetAddress = remoteAddress,
         Via = via,
         TransportScheme = this.parent.Scheme
     };
     this.serverCertificateAuthenticator = parent.ClientSecurityTokenManager.CreateSecurityTokenAuthenticator(tokenRequirement, out resolver);
     if (parent.RequireClientCertificate)
     {
         InitiatorServiceModelSecurityTokenRequirement requirement2 = new InitiatorServiceModelSecurityTokenRequirement {
             TokenType = SecurityTokenTypes.X509Certificate,
             RequireCryptographicToken = true,
             KeyUsage = SecurityKeyUsage.Signature,
             TargetAddress = remoteAddress,
             Via = via,
             TransportScheme = this.parent.Scheme
         };
         this.clientCertificateProvider = parent.ClientSecurityTokenManager.CreateSecurityTokenProvider(requirement2);
         if (this.clientCertificateProvider == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("ClientCredentialsUnableToCreateLocalTokenProvider", new object[] { requirement2 })));
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:SslStreamSecurityUpgradeInitiator.cs

示例7: GetFile

        public byte[] GetFile(ClassLibrary.Entites.File file, long partNumber)
        {
            PNRPManager manager = PeerServiceHost.PNRPManager;
            List<ClassLibrary.Entites.Peer> foundPeers = manager.ResolveByPeerName(file.PeerName);

            if (foundPeers.Count != 0) 
            {
                ClassLibrary.Entites.Peer peer = foundPeers.FirstOrDefault();

                EndpointAddress endpointAddress = new EndpointAddress(string.Format("net.tcp://{0}:{1}/PeerToPeerClient.Services/PeerService",
                    peer.PeerHostName, ClassLibrary.Config.LocalPort));

                NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None);
                PeerServiceClient client = new PeerServiceClient(tcpBinding, endpointAddress);

                byte[] data = null;

                try
                {
                    data = client.TransferFile(file, partNumber);
                }
                catch
                {
                    throw new Exception("Unreachable host '" + file.PeerName);
                }

                return data;
            }

            else
            {
                throw new Exception("Unable to resolve peer " +  file.PeerName);
            }
        }
开发者ID:BekaB,项目名称:PeerToPeer,代码行数:34,代码来源:TransferEngine.cs

示例8: ImitatorServiceFactory

		public ImitatorServiceFactory()
		{
			var binding = BindingHelper.CreateBindingFromAddress("net.pipe://127.0.0.1/GKImitator/");
			var endpointAddress = new EndpointAddress(new Uri("net.pipe://127.0.0.1/GKImitator/"));
			_channelFactory = new ChannelFactory<IImitatorService>(binding, endpointAddress);
			_channelFactory.Open();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:7,代码来源:ImitatorServiceFactory.cs

示例9: Main

        static void Main(string[] args)
        {
            Console.Title = "CLIENT";

            // Указание, где ожидать входящие сообщения.
            Uri address = new Uri("http://localhost:4000/IContract");  // ADDRESS.   (A)

            // Указание, как обмениваться сообщениями.
            BasicHttpBinding binding = new BasicHttpBinding();         // BINDING.   (B)

            // Создание Конечной Точки.
            EndpointAddress endpoint = new EndpointAddress(address);

            // Создание фабрики каналов.
            ChannelFactory<IContract> factory = new ChannelFactory<IContract>(binding, endpoint);  // CONTRACT.  (C) 

            // Использование factory для создания канала (прокси).
            IContract channel = factory.CreateChannel();
            
            // Использование канала для отправки сообщения получателю.
            channel.Say("Hello WCF!");// сложный механизм

            // Задержка.
            Console.ReadKey();
        }
开发者ID:novakvova,项目名称:WCFLesson1,代码行数:25,代码来源:Client.cs

示例10: Book

        public ViewResult Book(BookingModel model)
        {
            var request = new BookRequest
            {
                RoomNumber = model.RoomNumber,
                PersonName = model.PersonName,
                BeginAt = model.BeginAt,
                EndAt = model.EndAt
            };

            var binding = new NetTcpBinding();
            var endpointAddress = new EndpointAddress("net.tcp://localhost:9090");

            var channelFactory = new ChannelFactory<IBookingService>(binding, endpointAddress);

            var channel = channelFactory.CreateChannel(endpointAddress);

            var result = channel.Book(request);
            if (result.BookingStatus == BookingStatus.Approved)
            {
                @ViewBag.Title = "Booking completed";
                return View("Success", model);
            }

            @ViewBag.Title = "Booking failed";
            @ViewBag.Message = result.Message;

            return View("Failed");
        }
开发者ID:Codestellation,项目名称:DarkFlow,代码行数:29,代码来源:BookingController.cs

示例11: Main

        static void Main(string[] args)
        {
            CalculatorClient client1 = new CalculatorClient("calculatorservice");
            client1.Open();
            CalculatorClient client2 = new CalculatorClient("calculatorservice");
            client2.Open();

            client1.Close();
            client2.Close();

            Console.WriteLine("ChannelFactory的状态: {0}", client1.ChannelFactory.State);
            Console.WriteLine("ChannelFactory的状态: {0}\n", client2.ChannelFactory.State);

            EndpointAddress address = new EndpointAddress("http://127.0.0.1:3721/calculatorservice");
            Binding binding = new WS2007HttpBinding();

            CalculatorClient client3 = new CalculatorClient(binding, address);
            client3.Open();
            CalculatorClient client4 = new CalculatorClient(binding, address);
            client4.Open();

            client3.Close();
            client4.Close();

            Console.WriteLine("ChannelFactory的状态: {0}", client3.ChannelFactory.State);
            Console.WriteLine("ChannelFactory的状态: {0}", client4.ChannelFactory.State);

            Console.Read();
        }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:29,代码来源:Program.cs

示例12: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            //Banking_Library.IService1 proxy = new Banking_Library.Service1();
            EndpointAddress adddress = new EndpointAddress("http://localhost:8080/QuanLyDanhBa/QuanLyDanhBa");
            WSHttpBinding binding = new WSHttpBinding();

            ServiceLibrary.IQuanLyDanhBa proxy;
            proxy = ChannelFactory<ServiceLibrary.IQuanLyDanhBa>.CreateChannel(binding, adddress);
            // = new ServiceLibrary.ServiceQuanLyDanhBa();
            //IServiceBank proxy = new ServiceBankClient();
            textBox1.Text = proxy.GetAuthor();

            //*/
            //Dung ChannelFactory cho phep tao nhieu doi tuong proxy voi cac endpoint khac nhau
            //EndpointAddress address = new EndpointAddress("http://localhost:8000/BankService");
            //BasicHttpBinding binding = new BasicHttpBinding();
            //Banking_Library.IService1 proxy = ChannelFactory<Banking_Library.IService1>.CreateChannel(binding, address);
            //txtResult.Text = proxy.GetBalance("aaa").ToString();
            //IBankService proxy = ChannelFactory<IBankService>.CreateChannel(binding,  address);
            //decimal balance = proxy.GetBalance("ABC123");

            //Dung ChannelFactory cho phep tao nhieu doi tuong proxy voi cac endpoint khac nhau
            //EndpointAddress address1 = new EndpointAddress("http://localhost:8000/BankService1");
            //WSHttpBinding binding1 = new WSHttpBinding();
            //IBankService proxy1 = ChannelFactory<IBankService>.CreateChannel(binding1, address1);
            //decimal balance1 = proxy1.GetBalance("ABC123");

            //label1.Text = Convert.ToString(balance) + " and "  +  Convert.ToString(balance1);
        }
开发者ID:nguyen0863,项目名称:QuanLyDanhBaDienThoai,代码行数:29,代码来源:Form1.cs

示例13: SerialChannelBase

        /// <summary>
        /// SerialChannel Base
        /// </summary>
        /// <param name="bufferManager">
        /// Buffer manager created by factory and listener</param>
        /// <param name="encoderFactory">
        /// Referece to encoder factory as returned by encoder element</param>
        /// <param name="address">Remote address</param>
        /// <param name="portNumber">COM port number</param>
        /// <param name="parent">reference to factory/listener</param>
        /// <param name="maxReceivedMessageSize">
        /// Some settings for transport channel</param>
        public SerialChannelBase(BufferManager bufferManager, 
            MessageEncoderFactory encoderFactory, 
            EndpointAddress address,
            string portNumber,
            ChannelManagerBase parent,
            long maxReceivedMessageSize)
            : base(parent)
        {
            this.address = address;
            this.bufferManager = bufferManager;
            this.encoder = encoderFactory.CreateSessionEncoder();
            this.maxReceivedMessageSize = maxReceivedMessageSize;

            this.portNumber = portNumber;

            // Create port
            serialPort = new SerialPort();

            // Set the appropriate properties.
            serialPort.PortName = this.portNumber;
            //TODO: Read these settings from configuration file
            serialPort.BaudRate = 9600;
            serialPort.Parity = Parity.None;
            serialPort.DataBits = 8;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;

            // Set the read/write timeouts
            serialPort.ReadTimeout = 500;
            serialPort.WriteTimeout = 500;
        }
开发者ID:gitlabuser,项目名称:warehouse,代码行数:43,代码来源:SerialChannelBase.cs

示例14: TryGetToken

 public override bool TryGetToken(EndpointAddress target, EndpointAddress issuer, out GenericXmlSecurityToken cachedToken)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     cachedToken = null;
     lock (thisLock)
     {
         GenericXmlSecurityToken tmp;
         Key key = new Key(target.Uri, issuer == null ? null : issuer.Uri);
         if (this.cache.TryGetValue(key, out tmp))
         {
             // if the cached token is going to expire soon, remove it from the cache and return a cache miss
             if (tmp.ValidTo < DateTime.UtcNow + TimeSpan.FromMinutes(1))
             {
                 this.cache.Remove(key);
                 OnTokenRemoved(key);
             }
             else
             {
                 cachedToken = tmp;
             }
         }
     }
     return (cachedToken != null);
 }
开发者ID:ssickles,项目名称:archive,代码行数:27,代码来源:IssuedTokenCache.cs

示例15: Connect

        public void Connect(string endPointAddress)
        {
            if (this._lucidServer != null)
            {
                Disconnect();
            }

            EndpointAddress serverEndpointAddress;
            try
            {
                serverEndpointAddress = new EndpointAddress(endPointAddress);
            }
            catch
            {
                // bad url
                throw new Exception("Bad server URL: " + endPointAddress);
            }
            Binding binding = new NetTcpBinding(SecurityMode.None, true);
            binding.ReceiveTimeout = TimeSpan.FromSeconds(10);
            binding.SendTimeout = TimeSpan.FromSeconds(10);
            binding.OpenTimeout = TimeSpan.FromSeconds(10);
            var factory = new ChannelFactory<ILucidService>(binding, serverEndpointAddress);

            this._lucidServer = factory.CreateChannel();
            // let server know we are available
            this._lucidServer.RegisterClient();

            Inv.Log.Log.WriteMessage("Connected to server " + endPointAddress);
        }
开发者ID:mkonicek,项目名称:raytracer,代码行数:29,代码来源:LucidClient.cs


注:本文中的System.ServiceModel.EndpointAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。