Tôi có một Dịch vụ WCF với wsHttpBindings và SSL được kích hoạt, nhưng tôi muốn kích hoạt các phiên WCF.Làm thế nào để kích hoạt Phiên với SSL wsHttpBinding trong WCF
Sau khi thay đổi SessionMode thành bắt buộc
SessionMode:=SessionMode.Required
Tôi nhận được lỗi được mô tả dưới đây.
Hợp đồng yêu cầu Phiên, nhưng Ràng buộc 'WSHttpBinding' không hỗ trợ hoặc không được định cấu hình đúng để hỗ trợ.
Đây là ứng dụng mẫu của tôi.
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<client />
<bindings>
<wsHttpBinding>
<binding name="NewBinding0" useDefaultWebProxy="false" allowCookies="true">
<readerQuotas maxStringContentLength="10240" />
<!--reliableSession enabled="true" /-->
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" >
<extendedProtectionPolicy policyEnforcement="Never" />
</transport >
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WcfServiceLib.TestService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="NewBinding0"
contract="WcfServiceLib.ITestService">
<identity>
<servicePrincipalName value="Local Network" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://test/TestService.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
ITestService.vb
<ServiceContract(SessionMode:=SessionMode.Required)>
Public Interface ITestService
<OperationContract(IsInitiating:=True, IsTerminating:=False)> _
Function GetData(ByVal value As Integer) As String
End Interface
TestService.vb
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession, _
ReleaseServiceInstanceOnTransactionComplete:=False, _
ConcurrencyMode:=ConcurrencyMode.Single)>
Public Class TestService
Implements ITestService
Private _user As User
<OperationBehavior(TransactionScopeRequired:=True)>
Public Function GetData(ByVal value As Integer) As String _
Implements ITestService.GetData
If _user Is Nothing Then
_user = New User()
_user.userName = "User_" & value
_user.userPassword = "Pass_" & value
Return String.Format("You've entered: {0} , Username = {1} , Password = {2} ", _
value, _user.userName, _user.userPassword)
Else
Return String.Format("Username = {1} , Password = {2} ", _
_user.userName, _user.userPassword)
End If
End Function
End Class
Tôi đã thử tất cả po giải pháp ssible, tôi có thể tìm thấy, nhưng không có gì giúp đỡ.
Một số lời khuyên để giúp phiên đáng tin cậy, nhưng nó không làm việc với ssl (nếu chỉ có bạn có tùy chỉnh của bạn ràng buộc), lời khuyên người khác sử dụng http thay vì https, nhưng tôi muốn muốn bật Phiên có cấu hình hiện tại của tôi, nếu có thể.
Có cách tiếp cận nào để đạt được điều này không?
Mọi loại trợ giúp đều được đánh giá cao.
Lý do bật trạng thái phiên trên dịch vụ wcf là gì? Đây có thể là một nút cổ chai nếu bạn đang tìm kiếm hiệu suất cao. Dịch vụ wcf phiên trạng thái nên tránh. –
Tôi muốn có biến _user cho mỗi phiên. Tôi nhận được một phiên bản dịch vụ mới cho mọi cuộc gọi. Giá trị của _user luôn là Không có gì. – hgulyan
Tôi nên sử dụng giải pháp nào cho tình huống của mình, nếu tôi cần lưu trữ dữ liệu cho mọi khách hàng? – hgulyan