本文整理汇总了C#中TextMessageEncodingBindingElement类的典型用法代码示例。如果您正苦于以下问题:C# TextMessageEncodingBindingElement类的具体用法?C# TextMessageEncodingBindingElement怎么用?C# TextMessageEncodingBindingElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextMessageEncodingBindingElement类属于命名空间,在下文中一共展示了TextMessageEncodingBindingElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例6: TextMessageEncoderFactory
public TextMessageEncoderFactory (
TextMessageEncodingBindingElement owner)
{
this.owner = owner;
encoder = new TextMessageEncoder (
MessageVersion, owner.WriteEncoding);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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 });
}
示例11: HttpBindingBase
internal HttpBindingBase()
{
_httpTransport = new HttpTransportBindingElement();
_httpsTransport = new HttpsTransportBindingElement();
_textEncoding = new TextMessageEncodingBindingElement();
_textEncoding.MessageVersion = MessageVersion.Soap11;
_httpsTransport.WebSocketSettings = _httpTransport.WebSocketSettings;
}
示例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);
}
示例13: BuildChannelFactoryFail1
public void BuildChannelFactoryFail1 ()
{
MessageEncodingBindingElement be =
new TextMessageEncodingBindingElement ();
BindingContext ctx = new BindingContext (
// no transport -> fail
new CustomBinding (),
new BindingParameterCollection ());
be.BuildChannelFactory<IRequestChannel> (ctx);
}
示例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);
}
示例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()));
}
}