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

C# TextMessageEncodingBindingElement类代码示例

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

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



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

示例1: FillMessageEncoder

		void FillMessageEncoder (BindingContext ctx)
		{
			var mbe = (MessageEncodingBindingElement) ctx.Binding.Elements.FirstOrDefault (be => be is MessageEncodingBindingElement);
			if (mbe == null)
				mbe = new TextMessageEncodingBindingElement ();
			message_encoder = mbe.CreateMessageEncoderFactory ().Encoder;
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:UdpDuplexChannel.cs


示例2: CreateBindingElements

		private static IEnumerable<BindingElement> CreateBindingElements(bool mtomEncoding, bool wsAddressing, bool securityToken, bool useTls){
			var msgVer = wsAddressing ? 
				MessageVersion.Soap12WSAddressing10 :
				MessageVersion.Soap12;
			if(mtomEncoding){
				var encoding = new MtomMessageEncodingBindingElement(msgVer, Encoding.UTF8);
				encoding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
				encoding.MaxBufferSize = Int32.MaxValue;
				yield return encoding;
			}else{
				var encoding = new TextMessageEncodingBindingElement(msgVer, Encoding.UTF8);
				encoding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; //100 * 1024 * 1024
				yield return encoding;
			}

			//var security = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
			//security..M .MessageSecurityVersion = MessageSecurityVersion.

			HttpTransportBindingElement transport = CreateTransportBindingElement(useTls);
			transport.MaxReceivedMessageSize = Int32.MaxValue; //100L * 1024L * 1024L
			transport.KeepAliveEnabled = false;
			transport.MaxBufferSize = Int32.MaxValue;
			transport.ProxyAddress = null;
			transport.BypassProxyOnLocal = true;
			//transport.ManualAddressing = true
			transport.UseDefaultWebProxy = false;
			transport.TransferMode =TransferMode.StreamedResponse;
			//transport.TransferMode = TransfeStreamedResponse
			transport.AuthenticationScheme = AuthenticationSchemes.Basic;
			//transport.AuthenticationScheme = AuthenticationSchemes.Digest;
			
			yield return transport;
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:33,代码来源:OnvifFactory.cs


示例3: CreateHttpGetChannelDispatcher

        private static void CreateHttpGetChannelDispatcher(ServiceHostBase host, Uri listenUri, MetadataSet metadata)
        {
            //创建Binding
            TextMessageEncodingBindingElement messageEncodingElement = new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.None };
            HttpTransportBindingElement transportElement = new HttpTransportBindingElement();
            Utility.SetPropertyValue(transportElement, "Method", "GET");
            Binding binding = new CustomBinding(messageEncodingElement, transportElement);

            //创建ChannelListener
            IChannelListener listener = binding.BuildChannelListener<IReplyChannel>(listenUri, string.Empty, ListenUriMode.Explicit, new BindingParameterCollection());
            ChannelDispatcher dispatcher = new ChannelDispatcher(listener, "ServiceMetadataBehaviorHttpGetBinding", binding) { MessageVersion = binding.MessageVersion };

            //创建EndpointDispatcher
            EndpointDispatcher endpoint = new EndpointDispatcher(new EndpointAddress(listenUri), "IHttpGetMetadata", "http://www.artech.com/");

            //创建DispatchOperation,并设置DispatchMessageFormatter和OperationInvoker
            DispatchOperation operation = new DispatchOperation(endpoint.DispatchRuntime, "Get", "*", "*");
            operation.Formatter = Utility.CreateInstance<IDispatchMessageFormatter>(MessageOperationFormatterType, Type.EmptyTypes, new object[0]);
            MethodInfo method = typeof(IHttpGetMetadata).GetMethod("Get");
            operation.Invoker = Utility.CreateInstance<IOperationInvoker>(SyncMethodInvokerType, new Type[] { typeof(MethodInfo) }, new object[] { method });
            endpoint.DispatchRuntime.Operations.Add(operation);

            //设置SingletonInstanceContext和InstanceContextProvider
            MetadataProvisionService serviceInstance = new MetadataProvisionService(metadata);
            endpoint.DispatchRuntime.SingletonInstanceContext = new InstanceContext(host, serviceInstance);
            endpoint.DispatchRuntime.InstanceContextProvider = Utility.CreateInstance<IInstanceContextProvider>(SingletonInstanceContextProviderType, new Type[] { typeof(DispatchRuntime) }, new object[] { endpoint.DispatchRuntime });
            dispatcher.Endpoints.Add(endpoint);

            //设置ContractFilter和AddressFilter
            endpoint.ContractFilter = new MatchAllMessageFilter();
            endpoint.AddressFilter = new MatchAllMessageFilter();

            host.ChannelDispatchers.Add(dispatcher);
        }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:34,代码来源:ServiceMetadataBehaviorAttribute.cs


示例4: SyncUpEncodingBindingElementProperties

 internal static void SyncUpEncodingBindingElementProperties(TextMessageEncodingBindingElement textEncoding, MtomMessageEncodingBindingElement mtomEncoding)
 {
     // textEncoding provides the backing store for ReaderQuotas and WriteEncoding,
     // we must ensure same values propogate to mtomEncoding
     textEncoding.ReaderQuotas.CopyTo(mtomEncoding.ReaderQuotas);
     mtomEncoding.WriteEncoding = textEncoding.WriteEncoding;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:WSMessageEncoding.cs


示例5: GetBinding

        public static CustomBinding GetBinding()
        {
            // Same binding should be used in both service and service client.
            //var binding = new BasicHttpBinding();
            //binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            //SetTimeOuts(binding);
            //return binding;

            // Instantiate message encoding element and configure
            TextMessageEncodingBindingElement text = new TextMessageEncodingBindingElement();
            text.MessageVersion = MessageVersion.Soap11;
            text.ReaderQuotas.MaxStringContentLength = int.MaxValue;

            // Instantiate transport element and configure
            HttpTransportBindingElement http = new HttpTransportBindingElement();
            http.TransferMode = TransferMode.Buffered;
            http.UseDefaultWebProxy = true;

            CustomBinding binding = new CustomBinding();
            binding.Name = "MonoscapeHttpBinding";
            binding.Elements.Add(text);
            binding.Elements.Add(http);
            SetTimeOuts(binding);

            return binding;
        }
开发者ID:virajs,项目名称:monoscape,代码行数:26,代码来源:MonoscapeServiceHost.cs


示例6: TextMessageEncoderFactory

		public TextMessageEncoderFactory (
			TextMessageEncodingBindingElement owner)
		{
			this.owner = owner;
			encoder = new TextMessageEncoder (
				MessageVersion, owner.WriteEncoding);
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:TextMessageEncoderFactory.cs


示例7: Main

        static void Main(string[] args)
        {
            try
            {
                BindingElement[] bindingElements = new BindingElement[2];
                bindingElements[0] = new TextMessageEncodingBindingElement();
                bindingElements[1] = new HttpTransportBindingElement();

                CustomBinding binding = new CustomBinding(bindingElements);
                using (Message message = Message.CreateMessage(binding.MessageVersion, "sendMessage", "Message Body"))
                {
                    IChannelFactory<IRequestChannel> factory = binding.BuildChannelFactory<IRequestChannel>(new BindingParameterCollection());
                    factory.Open();

                    IRequestChannel requestChannel = factory.CreateChannel(new EndpointAddress("http://localhost:9090/RequestReplyService"));
                    requestChannel.Open();
                    Message response = requestChannel.Request(message);

                    Console.WriteLine("Successful send message!");

                    Console.WriteLine("Receive a return message, action: {0}, body: {1}", response.Headers.Action, response.GetBody<String>());
                    requestChannel.Close();
                    factory.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally {
                Console.Read();
            }
        }
开发者ID:porter1130,项目名称:MyTest,代码行数:33,代码来源:Output.cs


示例8: Main

        static void Main(string[] args)
        {
            try {
                BindingElement[] bindingElements = new BindingElement[2];
                bindingElements[0] = new TextMessageEncodingBindingElement();
                bindingElements[1] = new HttpTransportBindingElement();

                CustomBinding binding = new CustomBinding(bindingElements);

                IChannelListener<IReplyChannel> listener=binding.BuildChannelListener<IReplyChannel>(new Uri("http://localhost:9090/RequestReplyService"),new BindingParameterCollection());
                listener.Open();

                IReplyChannel replyChannel = listener.AcceptChannel();
                replyChannel.Open();
                Console.WriteLine("starting to receive message....");

                RequestContext requestContext = replyChannel.ReceiveRequest();
                Console.WriteLine("Received a Message, action:{0},body:{1}", requestContext.RequestMessage.Headers.Action,
                                    requestContext.RequestMessage.GetBody<string>());
                Message message = Message.CreateMessage(binding.MessageVersion, "response", "response Message");
                requestContext.Reply(message);

                requestContext.Close();
                replyChannel.Close();
                listener.Close();

            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
            finally {
                Console.Read();
            }
        }
开发者ID:porter1130,项目名称:MyTest,代码行数:34,代码来源:Program.cs


示例9: CreateMessageEncoding

 private MessageEncodingBindingElement CreateMessageEncoding()
 {
     TextMessageEncodingBindingElement encoding = new TextMessageEncodingBindingElement();
     encoding.MessageVersion = MessageVersion.Soap12;
     encoding.ReaderQuotas.MaxArrayLength = 1024 * 1024 * 1024; //1 GB
     encoding.ReaderQuotas.MaxStringContentLength = 1024 * 1024 * 1024; //1 GB
     return encoding;
 }
开发者ID:e-Contract,项目名称:dssp-client,代码行数:8,代码来源:PlainDsspBinding.cs


示例10: CreateGetBinding

 private static CustomBinding CreateGetBinding(HttpTransportBindingElement httpTransport)
 {
     TextMessageEncodingBindingElement element = new TextMessageEncodingBindingElement {
         MessageVersion = MessageVersion.None
     };
     httpTransport.Method = "GET";
     httpTransport.InheritBaseAddressSettings = true;
     return new CustomBinding(new BindingElement[] { element, httpTransport });
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:MetadataExchangeBindings.cs


示例11: HttpBindingBase

        internal HttpBindingBase()
        {
            _httpTransport = new HttpTransportBindingElement();
            _httpsTransport = new HttpsTransportBindingElement();

            _textEncoding = new TextMessageEncodingBindingElement();
            _textEncoding.MessageVersion = MessageVersion.Soap11;
            _httpsTransport.WebSocketSettings = _httpTransport.WebSocketSettings;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:9,代码来源:HttpBindingBase.cs


示例12: CreateBindingElement

 protected override BindingElement CreateBindingElement()
 {
     TextMessageEncodingBindingElement textBindingElement = new TextMessageEncodingBindingElement();
     if (null != this.TextEncoding)
     {
         this.TextEncoding.ApplyConfiguration(textBindingElement);
     }
     return new CompressionTextMessageEncodingBindingElement(textBindingElement, this.Algorithm, this.MinMessageSize);
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:9,代码来源:CompressionTextEncodingElement.cs


示例13: BuildChannelFactoryFail1

		public void BuildChannelFactoryFail1 ()
		{
			MessageEncodingBindingElement be =
				new TextMessageEncodingBindingElement ();
			BindingContext ctx = new BindingContext (
				// no transport -> fail
				new CustomBinding (),
				new BindingParameterCollection ());
			be.BuildChannelFactory<IRequestChannel> (ctx);
		}
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:MessageEncodingBindingElementTest.cs


示例14: WOPIMessageEncoder

        /// <summary>
        /// Initializes a new instance of the WOPIMessageEncoder class with the specified message encoder factory.
        /// </summary>
        /// <param name="factory">Specify the message encoder factory.</param>
        public WOPIMessageEncoder(WOPIMessageEncoderFactory factory)
        {
            TextMessageEncodingBindingElement element = new TextMessageEncodingBindingElement();
            element.MessageVersion = factory.MessageVersion;
            element.WriteEncoding = Encoding.GetEncoding(factory.CharSet);

            this.innerEncoder = element.CreateMessageEncoderFactory().Encoder;
            this.factory = factory;
            this.contentType = string.Format("{0}; charset={1}", "text/xml", this.factory.CharSet);
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:14,代码来源:WOPIMessageEncoder.cs


示例15: IRequestChannel_Http_CustomBinding

    public static void IRequestChannel_Http_CustomBinding()
    {
        try
        {
            BindingElement[] bindingElements = new BindingElement[2];
            bindingElements[0] = new TextMessageEncodingBindingElement();
            bindingElements[1] = new HttpTransportBindingElement();
            CustomBinding binding = new CustomBinding(bindingElements);

            // Create the channel factory for the request-reply message exchange pattern.
            IChannelFactory<IRequestChannel> factory =
            binding.BuildChannelFactory<IRequestChannel>(
                             new BindingParameterCollection());
            factory.Open();

            // Create the channel.
            IRequestChannel channel = factory.CreateChannel(
               new EndpointAddress(Endpoints.DefaultCustomHttp_Address));
            channel.Open();

            // Create the Message object to send to the service.
            Message requestMessage = Message.CreateMessage(
                binding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));

            // Send the Message and receive the Response.
            Message replyMessage = channel.Request(requestMessage);
            string replyMessageAction = replyMessage.Headers.Action;

            if (!string.Equals(replyMessageAction, action + "Response"))
            {
                Assert.True(false, String.Format("A response was received from the Service but it was not the expected Action, expected: {0} actual: {1}", action + "Response", replyMessageAction));
            }


            var replyReader = replyMessage.GetReaderAtBodyContents();
            string actualResponse = replyReader.ReadElementContentAsString();
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";
            if (!string.Equals(actualResponse, expectedResponse))
            {
                Assert.True(false, String.Format("Actual MessageBodyContent from service did not match the expected MessageBodyContent, expected: {0} actual: {1}", expectedResponse, actualResponse));
            }

            replyMessage.Close();
            channel.Close();
            factory.Close();
        }

        catch (Exception ex)
        {
            Assert.True(false, String.Format("Unexpected exception was caught: {0}", ex.ToString()));
        }
    }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:54,代码来源:RequestReplyChannelShapeTests.cs


示例16: HttpCookieSessionBinding

        public HttpCookieSessionBinding()
            : base()
        {
            sessionElement = new HttpCookieSessionBindingElement();

            transportElement = new HttpTransportBindingElement();
            transportElement.AllowCookies = true;

            encodingElement = new TextMessageEncodingBindingElement();
            encodingElement.MessageVersion = MessageVersion.Soap11WSAddressing10;
        }
开发者ID:ssickles,项目名称:archive,代码行数:11,代码来源:HttpCookieSessionBinding.cs


示例17: HttpBindingBase

        internal HttpBindingBase()
        {
            this.httpTransport = new HttpTransportBindingElement();
            this.httpsTransport = new HttpsTransportBindingElement();

            this.textEncoding = new TextMessageEncodingBindingElement();
            this.textEncoding.MessageVersion = MessageVersion.Soap11;
            this.mtomEncoding = new MtomMessageEncodingBindingElement();
            this.mtomEncoding.MessageVersion = MessageVersion.Soap11;

            this.httpsTransport.WebSocketSettings = this.httpTransport.WebSocketSettings;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:12,代码来源:HttpBindingBase.cs


示例18: BuildChannelFactory1

		public void BuildChannelFactory1 ()
		{
			MessageEncodingBindingElement be =
				new TextMessageEncodingBindingElement ();
			BindingContext ctx = new BindingContext (
				new CustomBinding (
					new HttpTransportBindingElement ()),
				new BindingParameterCollection ());
			// hmm, it returns HttpChannelFactory, not sure
			// if TextMessageEncodingBindingElement is considered.
			be.BuildChannelFactory<IRequestChannel> (ctx);
		}
开发者ID:nickchal,项目名称:pash,代码行数:12,代码来源:MessageEncodingBindingElementTest.cs


示例19: _createTextMessageEncodingBinding

        /// <summary>
        /// Create TextMessageEncodingBindingElement of specified Soap version with lengths set to int.MaxValue
        /// </summary>
        /// <param name="version">Soap Messaging version</param>
        /// <returns>Instance of TextMessageEncodingBindingElement</returns>
        private static TextMessageEncodingBindingElement _createTextMessageEncodingBinding(MessageVersion version)
        {
            TextMessageEncodingBindingElement rRet = new TextMessageEncodingBindingElement(version, Encoding.UTF8);

            rRet.ReaderQuotas.MaxArrayLength = int.MaxValue;
            rRet.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            rRet.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
            rRet.ReaderQuotas.MaxDepth = int.MaxValue;
            rRet.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;

            return rRet;
        }
开发者ID:bring0,项目名称:test4,代码行数:17,代码来源:SOAPHelp.cs


示例20: IRequestChannel_Http_CustomBinding

    public static void IRequestChannel_Http_CustomBinding()
    {
        IChannelFactory<IRequestChannel> factory = null;
        IRequestChannel channel = null;
        Message replyMessage = null;

        try
        {
            // *** SETUP *** \\
            BindingElement[] bindingElements = new BindingElement[2];
            bindingElements[0] = new TextMessageEncodingBindingElement();
            bindingElements[1] = new HttpTransportBindingElement();
            CustomBinding binding = new CustomBinding(bindingElements);

            // Create the channel factory for the request-reply message exchange pattern.
            factory = binding.BuildChannelFactory<IRequestChannel>(new BindingParameterCollection());
            factory.Open();

            // Create the channel.
            channel = factory.CreateChannel(new EndpointAddress(Endpoints.DefaultCustomHttp_Address));
            channel.Open();

            // Create the Message object to send to the service.
            Message requestMessage = Message.CreateMessage(
                binding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));

            // *** EXECUTE *** \\
            // Send the Message and receive the Response.
            replyMessage = channel.Request(requestMessage);

            // *** VALIDATE *** \\
            string replyMessageAction = replyMessage.Headers.Action;
            Assert.Equal(action + "Response", replyMessageAction);

            var replyReader = replyMessage.GetReaderAtBodyContents();
            string actualResponse = replyReader.ReadElementContentAsString();
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";
            Assert.Equal(expectedResponse, actualResponse);

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TextNode类代码示例发布时间:2022-05-24
下一篇:
C# TextMenu类代码示例发布时间: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