• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BinaryMessageEncodingBindingElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FileSystemDispatcher_Picks_Up_Existing_Messages

        public void FileSystemDispatcher_Picks_Up_Existing_Messages()
        {
            BinaryMessageEncodingBindingElement element = new BinaryMessageEncodingBindingElement();
            MessageEncoder encoder = element.CreateMessageEncoderFactory().Encoder;

            ServiceBusRuntime dispatchRuntime = new ServiceBusRuntime(new DirectDeliveryCore());
            var subscription = new SubscriptionEndpoint(Guid.NewGuid(), "File System Dispatcher", null, null, typeof(IContract), new FileSystemDispatcher(new ConverterMessageDeliveryWriterFactory(encoder,typeof(IContract)),Config.IncomingFilePath), new PassThroughMessageFilter());
            dispatchRuntime.Subscribe(subscription);

            ServiceBusRuntime listenerRuntime = new ServiceBusRuntime(new DirectDeliveryCore());
            var listener = new ListenerEndpoint(Guid.NewGuid(), "File System Listener", null, null, typeof(IContract), new FileSystemListener(new ConverterMessageDeliveryReaderFactory(encoder, typeof(IContract)),Config.IncomingFilePath, Config.ProcessedFilePath));
            listenerRuntime.AddListener(listener);
            listenerRuntime.Subscribe(new SubscriptionEndpoint(Guid.NewGuid(), "Pass through", null, null, typeof(IContract), new ActionDispatcher((se, md) => { }), new PassThroughMessageFilter()));

            var dispatchTester = new ServiceBusTest(dispatchRuntime);
            var listenerTester = new ServiceBusTest(listenerRuntime);

            string message = "test this thing";

            dispatchTester.StartAndStop(() =>
            {
                dispatchRuntime.PublishOneWay(typeof(IContract), "PublishThis", message);

                listenerTester.WaitForDeliveries(1, TimeSpan.FromSeconds(10), () =>
                {
                });
            });

            dispatchRuntime.RemoveSubscription(subscription);
        }
开发者ID:jezell,项目名称:iserviceoriented,代码行数:30,代码来源:TestFileSystemDispatchersAndListeners.cs


示例2: NetTcpBinding

 private NetTcpBinding(TcpTransportBindingElement transport,
               BinaryMessageEncodingBindingElement encoding,
               NetTcpSecurity security)
     : this()
 {
     _security = security;
 }
开发者ID:shijiaxing,项目名称:wcf,代码行数:7,代码来源:NetTcpBinding.cs


示例3: NetTcpBinding

 NetTcpBinding(TcpTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, TransactionFlowBindingElement context, ReliableSessionBindingElement session, NetTcpSecurity security)
     : this()
 {
     this.security = security;
     this.ReliableSession.Enabled = session != null;
     InitializeFrom(transport, encoding, context, session);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:NetTcpBinding.cs


示例4: CreateBinding

 private void CreateBinding()
 {
     Collection<BindingElement> bindingElementsInTopDownChannelStackOrder = new Collection<BindingElement>();
     BindingElement securityBindingElement = this.config.SecurityManager.GetSecurityBindingElement();
     if (securityBindingElement != null)
     {
         bindingElementsInTopDownChannelStackOrder.Add(securityBindingElement);
     }
     TcpTransportBindingElement item = new TcpTransportBindingElement {
         MaxReceivedMessageSize = this.config.MaxReceivedMessageSize,
         MaxBufferPoolSize = this.config.MaxBufferPoolSize,
         TeredoEnabled = true
     };
     MessageEncodingBindingElement encodingBindingElement = null;
     if (this.messageHandler != null)
     {
         encodingBindingElement = this.messageHandler.EncodingBindingElement;
     }
     if (encodingBindingElement == null)
     {
         BinaryMessageEncodingBindingElement element4 = new BinaryMessageEncodingBindingElement();
         this.config.ReaderQuotas.CopyTo(element4.ReaderQuotas);
         bindingElementsInTopDownChannelStackOrder.Add(element4);
     }
     else
     {
         bindingElementsInTopDownChannelStackOrder.Add(encodingBindingElement);
     }
     bindingElementsInTopDownChannelStackOrder.Add(item);
     this.binding = new CustomBinding(bindingElementsInTopDownChannelStackOrder);
     this.binding.ReceiveTimeout = TimeSpan.MaxValue;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:PeerService.cs


示例5: BuildCustomBinding

 internal static CustomBinding BuildCustomBinding(bool isSsl)
 {
     BinaryMessageEncodingBindingElement binary = new BinaryMessageEncodingBindingElement();
     HttpTransportBindingElement transport = isSsl ? new HttpsTransportBindingElement() : new HttpTransportBindingElement();
     transport.MaxBufferSize = 2147483647;
     transport.MaxReceivedMessageSize = 2147483647;
     return new CustomBinding(binary, transport);
 }
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:IdentityServiceProxy.cs


示例6: InitializeValue

        private void InitializeValue()
        {
            _compressionTypeOptions = CompressionTypeOptions.None;
            _operationBehaviours = new Dictionary<string, OperationBehaviourElement>();

            this._encoding = new BinaryMessageEncodingBindingElement();
            this._transport = GetTransport();
            this._mainTransport = new ProtoBufMetaDataBindingElement(this._transport);
        }
开发者ID:chenzuo,项目名称:ProtoBuf.Services,代码行数:9,代码来源:ProtoBufBinding.cs


示例7: CompressionFormat_Property_Sets

    public static void CompressionFormat_Property_Sets(CompressionFormat format)
    {
        BinaryMessageEncodingBindingElement bindingElement = new BinaryMessageEncodingBindingElement();
        bindingElement.CompressionFormat = format;
        Assert.Equal(format, bindingElement.CompressionFormat);

        // Note: invalid formats can be tested once we have a transport underneath, as it's the transport that determines 
        // whether or not the CompressionFormat is valid for it. 
    }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:9,代码来源:BinaryMessageEncodingBindingElementTest.cs


示例8: UaSoapXmlOverTcpBinding

        /// <summary>
        /// Initializes the binding.
        /// </summary>
        /// <param name="namespaceUris">The namespace uris.</param>
        /// <param name="factory">The factory.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="description">The description.</param>
        public UaSoapXmlOverTcpBinding(
            NamespaceTable        namespaceUris,
            EncodeableFactory     factory,
            EndpointConfiguration configuration,
            EndpointDescription   description)
        :
            base(namespaceUris, factory, configuration)
        {                   
            if (description != null && description.SecurityMode != MessageSecurityMode.None)
            {
                SymmetricSecurityBindingElement bootstrap = (SymmetricSecurityBindingElement)SecurityBindingElement.CreateMutualCertificateBindingElement();
                
                bootstrap.MessageProtectionOrder       = MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
                bootstrap.DefaultAlgorithmSuite        = SecurityPolicies.ToSecurityAlgorithmSuite(description.SecurityPolicyUri);
                bootstrap.IncludeTimestamp             = true;
                bootstrap.MessageSecurityVersion       = MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
                // bootstrap.MessageSecurityVersion       = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
                bootstrap.RequireSignatureConfirmation = false;
                bootstrap.SecurityHeaderLayout         = SecurityHeaderLayout.Strict;
                
                m_security = (SymmetricSecurityBindingElement)SecurityBindingElement.CreateSecureConversationBindingElement(bootstrap, true);
                
                m_security.MessageProtectionOrder       = MessageProtectionOrder.EncryptBeforeSign;
                m_security.DefaultAlgorithmSuite        = SecurityPolicies.ToSecurityAlgorithmSuite(description.SecurityPolicyUri);
                m_security.IncludeTimestamp             = true;
                m_security.MessageSecurityVersion       = MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
                // m_security.MessageSecurityVersion       = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
                m_security.RequireSignatureConfirmation = false;
                m_security.SecurityHeaderLayout         = SecurityHeaderLayout.Strict;

                m_security.SetKeyDerivation(true);
            }
            
            m_encoding = new BinaryMessageEncodingBindingElement();
           
            // WCF does not distinguish between arrays and byte string.
            int maxArrayLength = configuration.MaxArrayLength;

            if (configuration.MaxArrayLength < configuration.MaxByteStringLength)
            {
                maxArrayLength = configuration.MaxByteStringLength;
            }

            m_encoding.ReaderQuotas.MaxArrayLength         = maxArrayLength;
            m_encoding.ReaderQuotas.MaxStringContentLength = configuration.MaxStringLength;
            m_encoding.ReaderQuotas.MaxBytesPerRead        = Int32.MaxValue;
            m_encoding.ReaderQuotas.MaxDepth               = Int32.MaxValue;
            m_encoding.ReaderQuotas.MaxNameTableCharCount  = Int32.MaxValue;

            m_transport = new System.ServiceModel.Channels.TcpTransportBindingElement();

            m_transport.ManualAddressing       = false;
            m_transport.MaxBufferPoolSize      = Int32.MaxValue;
            m_transport.MaxReceivedMessageSize = configuration.MaxMessageSize;
        }
开发者ID:OPCFoundation,项目名称:Misc-Tools,代码行数:62,代码来源:UaSoapXmlOverTcpBinding.cs


示例9: Default_Ctor_Initializes_Properties

    public static void Default_Ctor_Initializes_Properties()
    {
        BinaryMessageEncodingBindingElement bindingElement = new BinaryMessageEncodingBindingElement();

        Assert.Equal<CompressionFormat>(CompressionFormat.None, bindingElement.CompressionFormat);
        Assert.Equal<int>(2048, bindingElement.MaxSessionSize);
        Assert.Equal<MessageVersion>(MessageVersion.Default, bindingElement.MessageVersion);

        Assert.True(TestHelpers.XmlDictionaryReaderQuotasAreEqual(bindingElement.ReaderQuotas, new XmlDictionaryReaderQuotas()),
            "BinaryEncodingBindingElement_DefaultCtor: Assert property 'XmlDictionaryReaderQuotas' == default value failed.");
    }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:11,代码来源:BinaryMessageEncodingBindingElementTest.cs


示例10: CreateAndWriteMessage

 private void CreateAndWriteMessage(byte[] bytes) {
   using (var stream = new MemoryStream(bytes, false)) {
     var mebe = new BinaryMessageEncodingBindingElement();
     mebe.MessageVersion = MessageVersion.Soap12;
     mebe.ReaderQuotas.MaxArrayLength = XmlDictionaryReaderQuotas.Max.MaxArrayLength;
     mebe.ReaderQuotas.MaxDepth = XmlDictionaryReaderQuotas.Max.MaxDepth;
     mebe.ReaderQuotas.MaxStringContentLength = XmlDictionaryReaderQuotas.Max.MaxStringContentLength;
     var factory = mebe.CreateMessageEncoderFactory();
     var msg = factory.Encoder.ReadMessage(stream, 1024 * 16);     // I have no idea what header size to give it ...
     WriteMessage(msg);
   }
 }
开发者ID:IdeaBlade,项目名称:DevForce.Utilities,代码行数:12,代码来源:DevForceMessageInspector.cs


示例11: InitializeFrom

 private void InitializeFrom(NamedPipeTransportBindingElement namedPipe, BinaryMessageEncodingBindingElement encoding, TransactionFlowBindingElement context)
 {
     this.Initialize();
     this.HostNameComparisonMode = namedPipe.HostNameComparisonMode;
     this.MaxBufferPoolSize = namedPipe.MaxBufferPoolSize;
     this.MaxBufferSize = namedPipe.MaxBufferSize;
     this.MaxConnections = namedPipe.MaxPendingConnections;
     this.MaxReceivedMessageSize = namedPipe.MaxReceivedMessageSize;
     this.TransferMode = namedPipe.TransferMode;
     this.ReaderQuotas = encoding.ReaderQuotas;
     this.TransactionFlow = context.Transactions;
     this.TransactionProtocol = context.TransactionProtocol;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:NetNamedPipeBinding.cs


示例12: NetHttpBinding

        public NetHttpBinding(NetHttpSecurityMode securityMode)
        {
            if (securityMode != NetHttpSecurityMode.Transport &&
                securityMode != NetHttpSecurityMode.TransportCredentialOnly &&
                securityMode != NetHttpSecurityMode.None)
            {
                throw new ArgumentOutOfRangeException("securityMode");
            }

            this.securityMode = securityMode;   
            this.httpTransport = new HttpTransportBindingElement();
            this.httpsTransport = new HttpsTransportBindingElement();
            this.binaryEncoding = new BinaryMessageEncodingBindingElement();
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:14,代码来源:NetHttpBinding.cs


示例13: ChatServer

        public ChatServer()
        {
            BinaryMessageEncodingBindingElement element = new BinaryMessageEncodingBindingElement();
            MessageEncoder encoder = element.CreateMessageEncoderFactory().Encoder;

            MessageDeliveryFormatter formatter = new MessageDeliveryFormatter(new ConverterMessageDeliveryReaderFactory(encoder, typeof(IChatService)), new ConverterMessageDeliveryWriterFactory(encoder, typeof(IChatService)));
            _serviceBus = new ServiceBusRuntime(new DirectDeliveryCore() , new WcfManagementService());
            _serviceBus.AddListener(new ListenerEndpoint(Guid.NewGuid(), "Chat Service", "ChatServer", "http://localhost/chatServer", typeof(IChatService), new WcfServiceHostListener()));
            _serviceBus.Subscribe(new SubscriptionEndpoint(Guid.NewGuid(), "No subscribers", "ChatClient", "", typeof(IChatService), new MethodDispatcher(new UnhandledReplyHandler(_serviceBus)), new UnhandledMessageFilter(typeof(SendMessageRequest)), true));
            _serviceBus.UnhandledException+= (o, ex) =>
                {
                    Console.WriteLine("Unhandled Exception: "+ex.ExceptionObject);
                };
        }
开发者ID:jezell,项目名称:iserviceoriented,代码行数:14,代码来源:ChatServer.cs


示例14: Main

        static void Main(string[] args)
        {
            // TODO: extract into a properties file
            string serviceName = "CAService";
            string baseAddress = "net.tcp://localhost:3333/";
            ServiceHost caHost = new ServiceHost(typeof(Simulation), new Uri(baseAddress + serviceName));

            try {
                // Configure the TCP binding
                NetTcpBinding tcpBinding = new NetTcpBinding();
                tcpBinding.MaxReceivedMessageSize = Int32.MaxValue;
                tcpBinding.MaxBufferPoolSize = Int32.MaxValue;
                tcpBinding.ReaderQuotas.MaxArrayLength = Int32.MaxValue;

                // Configure a binary message encoding binding element
                BinaryMessageEncodingBindingElement binaryBinding = new BinaryMessageEncodingBindingElement();
                binaryBinding.ReaderQuotas.MaxArrayLength = Int32.MaxValue;
                binaryBinding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;
                binaryBinding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;

                // Configure a MEX TCP binding to send metadata
                CustomBinding mexBinding = new CustomBinding(MetadataExchangeBindings.CreateMexTcpBinding());
                mexBinding.Elements.Insert(0, binaryBinding);
                mexBinding.Elements.Find<TcpTransportBindingElement>().MaxReceivedMessageSize = Int32.MaxValue;

                // Configure the host
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                caHost.Description.Behaviors.Add(smb);
                caHost.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, baseAddress + serviceName + "/mex");
                caHost.AddServiceEndpoint(typeof(ICAService), tcpBinding, baseAddress + serviceName);
                ServiceDebugBehavior debug = caHost.Description.Behaviors.Find<ServiceDebugBehavior>();
                if (debug == null) caHost.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
                else if (!debug.IncludeExceptionDetailInFaults) debug.IncludeExceptionDetailInFaults = true;

                // Open the host and run until Enter is pressed
                caHost.Open();
                Console.WriteLine("CA Simulator Server is running. Press Enter to exit.");
                Console.ReadLine();
                caHost.Close();
            }
            catch (CommunicationException e) {
                Console.WriteLine(e.Message);
                caHost.Abort();
            }
            catch (InvalidOperationException e) {
                Console.WriteLine(e.Message);
                caHost.Abort();
            }
        }
开发者ID:JWCook,项目名称:Client-Server_CA_Sim,代码行数:50,代码来源:CAServer.cs


示例15: GeocachingLiveV6

        public GeocachingLiveV6(bool testSite)
        {

            BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement()
            {
                ReaderQuotas = new XmlDictionaryReaderQuotas()
                {
                    MaxStringContentLength = int.MaxValue,
                    MaxBytesPerRead = int.MaxValue,
                    MaxDepth = int.MaxValue,
                    MaxArrayLength = int.MaxValue
                }
            };

            HttpTransportBindingElement httpTransport = new HttpsTransportBindingElement()
            {
                MaxBufferSize = int.MaxValue,
                MaxReceivedMessageSize = int.MaxValue,
                AllowCookies = false,
                //UseDefaultWebProxy = true,
            };

            // add the binding elements into a Custom Binding
            CustomBinding binding = new CustomBinding(binaryMessageEncoding, httpTransport);

            EndpointAddress endPoint;
            if (testSite)
            {
                endPoint = new EndpointAddress("https://staging.api.groundspeak.com/Live/V6Beta/geocaching.svc/Silverlightsoap");
                _token = Core.Settings.Default.LiveAPITokenStaging;
            }
            else
            {
                endPoint = new EndpointAddress("https://api.groundspeak.com/LiveV6/Geocaching.svc/Silverlightsoap");
                _token = Core.Settings.Default.LiveAPIToken;
            }

            try
            {
                _client = new LiveV6.LiveClient(binding, endPoint);
            }
            catch(Exception e)
            {
                Core.ApplicationData.Instance.Logger.AddLog(this, e);
            }

        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:47,代码来源:GeocachingLive.cs


示例16: GeocachingLiveV6

        public GeocachingLiveV6(Framework.Interfaces.ICore core, bool testSite)
        {
            _core = core;

            BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement()
            {
                ReaderQuotas = new XmlDictionaryReaderQuotas()
                {
                    MaxStringContentLength = int.MaxValue,
                    MaxBytesPerRead = int.MaxValue,
                    MaxDepth = int.MaxValue,
                    MaxArrayLength = int.MaxValue
                }
            };

            HttpTransportBindingElement httpTransport = new HttpsTransportBindingElement() 
            { 
                MaxBufferSize = int.MaxValue, 
                MaxReceivedMessageSize = int.MaxValue,
                AllowCookies = false, 
            };

            // add the binding elements into a Custom Binding
            CustomBinding binding = new CustomBinding(binaryMessageEncoding, httpTransport);            

            EndpointAddress endPoint;
            if (testSite)
            {
                endPoint = new EndpointAddress("https://staging.api.groundspeak.com/Live/V6Beta/geocaching.svc/Silverlightsoap");
                _token = core.GeocachingComAccount.APITokenStaging;
            }
            else
            {
                endPoint = new EndpointAddress("https://api.groundspeak.com/LiveV6/Geocaching.svc/Silverlightsoap");
                _token = core.GeocachingComAccount.APIToken;
            }

            try
            {
                _client = new LiveV6.LiveClient(binding, endPoint);
            }
            catch
            {
            }

        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:46,代码来源:GeocachingLive.cs


示例17: FileDownloadService

        public FileDownloadService()
        {
            TcpTransportBindingElement transport = new TcpTransportBindingElement();
            transport.MaxReceivedMessageSize = long.MaxValue;
            transport.MaxBufferSize = int.MaxValue;
            transport.MaxBufferPoolSize = long.MaxValue;
            transport.TransferMode = TransferMode.Streamed;

            BinaryMessageEncodingBindingElement encoder = new BinaryMessageEncodingBindingElement();
            CustomBinding binding = new CustomBinding(encoder, transport);
            binding.ReceiveTimeout = TimeSpan.MaxValue;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.CloseTimeout = TimeSpan.MaxValue;

            serviceHost = new ServiceHost(this);
            serviceHost.AddServiceEndpoint(typeof(IFileDownloadService), binding, "net.tcp://localhost:8020");
            serviceHost.Open();
        }
开发者ID:jonathanhook,项目名称:ReflecTable,代码行数:18,代码来源:FileDownloadService.cs


示例18: InitializeValue

		private void InitializeValue()
		{
			this.transport = new HttpTransportBindingElement();
			this.transport.MaxBufferSize = int.MaxValue;
			this.transport.MaxReceivedMessageSize = int.MaxValue;
			this.transport.TransferMode = System.ServiceModel.TransferMode.Streamed;
			
			this.ReceiveTimeout = TimeSpan.MaxValue;
			this.SendTimeout = TimeSpan.MaxValue;
			this.CloseTimeout = TimeSpan.MaxValue;
			this.Name = "FileStreaming";

			//this.Security.Mode = BasicHttpSecurityMode.None;

			this.encoding = new BinaryMessageEncodingBindingElement();
			this.encoding.ReaderQuotas.MaxArrayLength = int.MaxValue;
			this.encoding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
		}
开发者ID:dizzydezz,项目名称:jmm,代码行数:18,代码来源:CustomHttpBinding.cs


示例19: CreateBindingElements

        public override BindingElementCollection CreateBindingElements()
        {
            BinaryMessageEncodingBindingElement encoding = new BinaryMessageEncodingBindingElement();

            ZMQTransportBindingElement transport = new ZMQTransportBindingElement(Scheme, SocketMode);

            if (ReaderQuotas != null)
            {
                ReaderQuotas.CopyTo(encoding.ReaderQuotas);
            }

            BindingElementCollection collection = new BindingElementCollection
                {
                    encoding,
                    transport
                };

            return collection;
        }
开发者ID:ronybot,项目名称:MessageBus,代码行数:19,代码来源:ZMQBinding.cs


示例20: Main

	public static void Main ()
	{
Console.WriteLine ("WARNING!! This test is not configured enought to work fine on .NET either.");

		SymmetricSecurityBindingElement sbe =
			new SymmetricSecurityBindingElement ();
		sbe.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
		sbe.RequireSignatureConfirmation = true;
		//sbe.IncludeTimestamp = false;

		sbe.ProtectionTokenParameters =
			new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.Never);
		X509SecurityTokenParameters p =
			new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.AlwaysToRecipient);
		p.RequireDerivedKeys = false;
		sbe.EndpointSupportingTokenParameters.Endorsing.Add (p);
		//sbe.SetKeyDerivation (false);
		//sbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
		ServiceHost host = new ServiceHost (typeof (Foo));
		var mbe = new BinaryMessageEncodingBindingElement ();
		var tbe = new TcpTransportBindingElement ();
		CustomBinding binding = new CustomBinding (sbe, mbe, tbe);
		binding.ReceiveTimeout = TimeSpan.FromSeconds (5);
		host.AddServiceEndpoint ("IFoo",
			binding, new Uri ("http://localhost:8080"));
		ServiceCredentials cred = new ServiceCredentials ();
		cred.ServiceCertificate.Certificate =
			new X509Certificate2 ("test.pfx", "mono");
		cred.ClientCertificate.Authentication.CertificateValidationMode =
			X509CertificateValidationMode.None;
		host.Description.Behaviors.Add (cred);
		host.Description.Behaviors.Find<ServiceDebugBehavior> ()
			.IncludeExceptionDetailInFaults = true;
		ServiceMetadataBehavior smb = new ServiceMetadataBehavior ();
		smb.HttpGetEnabled = true;
		smb.HttpGetUrl = new Uri ("http://localhost:8080/wsdl");
		host.Description.Behaviors.Add (smb);
		host.Open ();
		Console.WriteLine ("Hit [CR] key to close ...");
		Console.ReadLine ();
		host.Close ();
	}
开发者ID:alesliehughes,项目名称:olive,代码行数:42,代码来源:samplesvc15.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BinaryOp类代码示例发布时间:2022-05-24
下一篇:
C# BinaryFormatter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap