本文整理汇总了C#中HttpTransportBindingElement类的典型用法代码示例。如果您正苦于以下问题:C# HttpTransportBindingElement类的具体用法?C# HttpTransportBindingElement怎么用?C# HttpTransportBindingElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpTransportBindingElement类属于命名空间,在下文中一共展示了HttpTransportBindingElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: JsonRpcHttpBinding
public JsonRpcHttpBinding()
: base()
{
transport = new HttpTransportBindingElement();
encoding = new WebMessageEncodingBindingElement();
encoding.ContentTypeMapper = new JsonRpcRawMapper();
}
开发者ID:kmvi,项目名称:JsonRpc.ServiceModel,代码行数:7,代码来源:JsonRpcHttpBinding.cs
示例2: 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
示例3: 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
示例4: ConfigureAuthentication
private void ConfigureAuthentication(HttpTransportBindingElement http)
{
http.AuthenticationScheme = HttpClientCredentialTypeHelper.MapToAuthenticationScheme(this.clientCredentialType);
http.ProxyAuthenticationScheme = HttpProxyCredentialTypeHelper.MapToAuthenticationScheme(this.proxyCredentialType);
http.Realm = this.Realm;
http.ExtendedProtectionPolicy = this.extendedProtectionPolicy;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:HttpTransportSecurity.cs
示例5: DisableAuthentication
private void DisableAuthentication(HttpTransportBindingElement http)
{
http.AuthenticationScheme = AuthenticationSchemes.Anonymous;
http.ProxyAuthenticationScheme = AuthenticationSchemes.Anonymous;
http.Realm = "";
http.ExtendedProtectionPolicy = this.extendedProtectionPolicy;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:HttpTransportSecurity.cs
示例6: CanBuildChannelFactory
public void CanBuildChannelFactory ()
{
// with HttpTransport
var m = new WebMessageEncodingBindingElement ();
Assert.IsTrue (m.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext ()), "#1");
Assert.IsFalse (m.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext ()), "#2");
Assert.IsFalse (m.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext ()), "#3");
Assert.IsFalse (m.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext ()), "#4");
// actually they are from transport
var h = new HttpTransportBindingElement ();
Assert.IsTrue (h.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext ()), "#5");
Assert.IsFalse (h.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext ()), "#6");
Assert.IsFalse (h.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext ()), "#7");
Assert.IsFalse (h.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext ()), "#8");
// with TcpTransport
Assert.IsFalse (m.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext2 ()), "#9");
Assert.IsFalse (m.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext2 ()), "#10");
Assert.IsFalse (m.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext2 ()), "#11");
Assert.IsFalse (m.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext2 ()), "#12");
// ... yes, actually they are from transport
var t = new TcpTransportBindingElement ();
Assert.IsFalse (t.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext2 ()), "#13");
Assert.IsFalse (t.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext2 ()), "#14");
Assert.IsFalse (t.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext2 ()), "#15");
Assert.IsFalse (t.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext2 ()), "#16");
}
开发者ID:BrzVlad,项目名称:mono,代码行数:29,代码来源:WebMessageEncodingBindingElementTest.cs
示例7: InitializeFrom
private void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, System.ServiceModel.Channels.TransactionFlowBindingElement txFlow, System.ServiceModel.Channels.ReliableSessionBindingElement session)
{
this.BypassProxyOnLocal = transport.BypassProxyOnLocal;
this.HostNameComparisonMode = transport.HostNameComparisonMode;
this.MaxBufferPoolSize = transport.MaxBufferPoolSize;
this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize;
this.ProxyAddress = transport.ProxyAddress;
this.UseDefaultWebProxy = transport.UseDefaultWebProxy;
if (encoding is TextMessageEncodingBindingElement)
{
this.MessageEncoding = WSMessageEncoding.Text;
TextMessageEncodingBindingElement element = (TextMessageEncodingBindingElement) encoding;
this.TextEncoding = element.WriteEncoding;
this.ReaderQuotas = element.ReaderQuotas;
}
else if (encoding is MtomMessageEncodingBindingElement)
{
this.messageEncoding = WSMessageEncoding.Mtom;
MtomMessageEncodingBindingElement element2 = (MtomMessageEncodingBindingElement) encoding;
this.TextEncoding = element2.WriteEncoding;
this.ReaderQuotas = element2.ReaderQuotas;
}
this.TransactionFlow = txFlow.Transactions;
this.reliableSession.Enabled = session != null;
if (session != null)
{
this.session.InactivityTimeout = session.InactivityTimeout;
this.session.Ordered = session.Ordered;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:WSHttpBindingBase.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: 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
示例10: Main
public static void Main ()
{
HttpTransportBindingElement el =
new HttpTransportBindingElement ();
BindingContext bc = new BindingContext (
new CustomBinding (),
new BindingParameterCollection (),
new Uri ("http://localhost:37564"),
String.Empty, ListenUriMode.Explicit);
IChannelListener<IReplyChannel> listener =
el.BuildChannelListener<IReplyChannel> (bc);
listener.Open ();
IReplyChannel reply = listener.AcceptChannel ();
reply.Open ();
if (!reply.WaitForRequest (TimeSpan.FromSeconds (10))) {
Console.WriteLine ("No request reached here.");
return;
}
Console.WriteLine ("Receiving request ...");
RequestContext ctx = reply.ReceiveRequest ();
if (ctx == null)
return;
Console.WriteLine ("Starting reply ...");
ctx.Reply (Message.CreateMessage (MessageVersion.Default, "Ack"));
}
开发者ID:alesliehughes,项目名称:olive,代码行数:29,代码来源:reply.cs
示例11: Main
// Host the service within this EXE console application.
public static void Main()
{
Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");
// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
// Create a custom binding containing two binding elements
ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
reliableSession.Ordered = true;
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
CustomBinding binding = new CustomBinding(reliableSession, httpTransport);
// Add an endpoint using that binding
serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, "");
// Open the ServiceHost to create listeners and start listening for messages.
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
}
}
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:31,代码来源:service.cs
示例12: GetSecurityModeFromTransport
private static bool GetSecurityModeFromTransport(HttpTransportBindingElement http, HttpTransportSecurity transportSecurity, out UnifiedSecurityMode mode)
{
mode = UnifiedSecurityMode.None;
if (http == null)
{
return false;
}
if (http is HttpsTransportBindingElement)
{
mode = UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Transport;
BasicHttpSecurity.EnableTransportSecurity((HttpsTransportBindingElement) http, transportSecurity);
}
else if (HttpTransportSecurity.IsDisabledTransportAuthentication(http))
{
mode = UnifiedSecurityMode.Message | UnifiedSecurityMode.None;
}
else
{
if (!BasicHttpSecurity.IsEnabledTransportAuthentication(http, transportSecurity))
{
return false;
}
mode = UnifiedSecurityMode.TransportCredentialOnly;
}
return true;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:BasicHttpBinding.cs
示例13: Main
public static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:8000/servicesamplemodel/service");
using (ServiceHost host = new ServiceHost(typeof(Service), baseAddress))
{
ReliableSessionBindingElement reliableBinding = new ReliableSessionBindingElement();
reliableBinding.Ordered = true;
HttpTransportBindingElement httpBindingElement = new HttpTransportBindingElement();
httpBindingElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpBindingElement.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
CustomBinding customBinding = new CustomBinding(reliableBinding, httpBindingElement);
host.AddServiceEndpoint(typeof(ICalculator), customBinding, "");
host.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
}
}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:26,代码来源:Service.cs
示例14: Main
public static void Main ()
{
SymmetricSecurityBindingElement sbe =
new SymmetricSecurityBindingElement ();
sbe.ProtectionTokenParameters =
new SslSecurityTokenParameters ();
ServiceHost host = new ServiceHost (typeof (Foo));
HttpTransportBindingElement hbe =
new HttpTransportBindingElement ();
CustomBinding binding = new CustomBinding (sbe, hbe);
binding.ReceiveTimeout = TimeSpan.FromSeconds (5);
host.AddServiceEndpoint ("IFoo",
binding, new Uri ("http://localhost:8080"));
ServiceCredentials cred = new ServiceCredentials ();
cred.SecureConversationAuthentication.SecurityStateEncoder =
new MyEncoder ();
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;
// foreach (ServiceEndpoint se in host.Description.Endpoints)
// se.Behaviors.Add (new StdErrInspectionBehavior ());
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,代码行数:34,代码来源:samplesvc10.cs
示例15: Main
public static void Main ()
{
HttpTransportBindingElement el =
new HttpTransportBindingElement ();
IChannelFactory<IRequestChannel> factory =
el.BuildChannelFactory<IRequestChannel> (
new BindingContext (new CustomBinding (),
new BindingParameterCollection ()));
factory.Open ();
IRequestChannel request = factory.CreateChannel (
new EndpointAddress ("http://localhost:37564"));
request.Open ();
using (XmlWriter w = XmlWriter.Create (Console.Out)) {
Message.CreateMessage (MessageVersion.Default, "Echo")
.WriteMessage (w);
}
Console.WriteLine ();
Message msg = request.Request (
Message.CreateMessage (MessageVersion.Default, "Echo"),
TimeSpan.FromSeconds (15));
using (XmlWriter w = XmlWriter.Create (Console.Out)) {
msg.WriteMessage (w);
}
}
开发者ID:alesliehughes,项目名称:olive,代码行数:29,代码来源:request.cs
示例16: GetDuplexServiceProxyClient
public static DuplexServiceClient GetDuplexServiceProxyClient()
{
string baseServiceUrl = Application.Current.Resources["BaseServiceUrl"].ToString();
EndpointAddress address = new EndpointAddress(baseServiceUrl + "DuplexService/PhasorDataDuplexService.svc");
CustomBinding binding;
if (HtmlPage.Document.DocumentUri.Scheme.ToLower().StartsWith("https"))
{
HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement();
httpsTransportBindingElement.MaxReceivedMessageSize = int.MaxValue;
binding = new CustomBinding(
new PollingDuplexBindingElement(),
new BinaryMessageEncodingBindingElement(),
httpsTransportBindingElement
);
}
else
{
HttpTransportBindingElement httpTransportBindingElement = new HttpTransportBindingElement();
httpTransportBindingElement.MaxReceivedMessageSize = int.MaxValue; // 65536 * 50;
binding = new CustomBinding(
new PollingDuplexBindingElement(),
new BinaryMessageEncodingBindingElement(),
httpTransportBindingElement
);
}
binding.CloseTimeout = new TimeSpan(0, 20, 0);
binding.OpenTimeout = new TimeSpan(0, 20, 0);
binding.ReceiveTimeout = new TimeSpan(0, 20, 0);
binding.SendTimeout = new TimeSpan(0, 20, 0);
return new DuplexServiceClient(binding, address);
}
开发者ID:JiahuiGuo,项目名称:openPDC,代码行数:33,代码来源:ProxyClient.cs
示例17: DisableAuthentication
private void DisableAuthentication(HttpTransportBindingElement http)
{
http.AuthenticationScheme = AuthenticationSchemes.Anonymous;
http.Realm = DefaultRealm;
//ExtendedProtectionPolicy is always copied - even for security mode None, Message and TransportWithMessageCredential,
//because the settings for ExtendedProtectionPolicy are always below the <security><transport> element
//http.ExtendedProtectionPolicy = this.extendedProtectionPolicy;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:8,代码来源:HttpTransportSecurity.cs
示例18: ConfigureTransportAuthentication
internal void ConfigureTransportAuthentication(HttpTransportBindingElement http)
{
if (this.clientCredentialType == HttpClientCredentialType.Certificate)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CertificateUnsupportedForHttpTransportCredentialOnly")));
}
this.ConfigureAuthentication(http);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:HttpTransportSecurity.cs
示例19: CreateHttpsFromHttp
private static HttpsTransportBindingElement CreateHttpsFromHttp(HttpTransportBindingElement http)
{
if (http == null)
{
return new HttpsTransportBindingElement();
}
return HttpsTransportBindingElement.CreateFromHttpBindingElement(http);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:TransportBindingElementImporter.cs
示例20: 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
注:本文中的HttpTransportBindingElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论