本文整理汇总了VB.NET中System.ServiceModel.Channels.SecurityBindingElement.LocalClientSettings属性的典型用法代码示例。如果您正苦于以下问题:VB.NET SecurityBindingElement.LocalClientSettings属性的具体用法?VB.NET SecurityBindingElement.LocalClientSettings怎么用?VB.NET SecurityBindingElement.LocalClientSettings使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了SecurityBindingElement.LocalClientSettings属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Run
' This method returns a custom binding created from a WSHttpBinding. Alter the method
' to use the appropriate binding for your service, with the appropriate settings.
Public Shared Function CreateCustomBinding(ByVal clockSkew As TimeSpan) As Binding
Dim standardBinding As WSHttpBinding = New WSHttpBinding(SecurityMode.Message, True)
Dim myCustomBinding As CustomBinding = New CustomBinding(standardBinding)
Dim security As SymmetricSecurityBindingElement = _
myCustomBinding.Elements.Find(Of SymmetricSecurityBindingElement)()
security.LocalClientSettings.MaxClockSkew = clockSkew
security.LocalServiceSettings.MaxClockSkew = clockSkew
' Get the System.ServiceModel.Security.Tokens.SecureConversationSecurityTokenParameters
Dim secureTokenParams As SecureConversationSecurityTokenParameters = _
CType(security.ProtectionTokenParameters, SecureConversationSecurityTokenParameters)
' From the collection, get the bootstrap element.
Dim bootstrap As SecurityBindingElement = secureTokenParams.BootstrapSecurityBindingElement
' Set the MaxClockSkew on the bootstrap element.
bootstrap.LocalClientSettings.MaxClockSkew = clockSkew
bootstrap.LocalServiceSettings.MaxClockSkew = clockSkew
Return myCustomBinding
End Function
Private Sub Run()
' Create a custom binding using the method defined above. The MaxClockSkew is set to 30 minutes.
Dim customBinding As Binding = CreateCustomBinding(TimeSpan.FromMinutes(30))
' Create a ServiceHost instance, and add a metadata endpoint.
' NOTE When using Visual Studio, you must run as administrator.
Dim baseUri As New Uri("http://localhost:1008/")
Dim sh As New ServiceHost(GetType(Calculator), baseUri)
' Optional. Add a metadata endpoint. The method is defined below.
AddMetadataEndpoint(sh)
' Add an endpoint using the binding, and open the service.
sh.AddServiceEndpoint(GetType(ICalculator), customBinding, "myCalculator")
sh.Open()
Console.WriteLine("Listening...")
Console.ReadLine()
End Sub
Private Sub AddMetadataEndpoint(ByRef sh As ServiceHost)
Dim mex As New Uri("http://localhost:1011/metadata/")
Dim sm As New ServiceMetadataBehavior()
sm.HttpGetEnabled = True
sm.HttpGetUrl = mex
sh.Description.Behaviors.Add(sm)
End Sub
开发者ID:VB.NET开发者,项目名称:System.ServiceModel.Channels,代码行数:50,代码来源:SecurityBindingElement.LocalClientSettings