wsHttpBindingsとSSLを有効にしたWCFサービスがありますが、WCFセッションを有効にしたいと思います。WCFでSSL wsHttpBindingを使用してセッションを有効にする方法
必要
SessionMode:=SessionMode.Required
にSessionModeを変更した後、私は以下のエラーを取得しています。
契約ではセッションが必要ですが、バインディング 'WSHttpBinding'は をサポートしていないか、サポートするように正しく設定されていません。
ここにサンプルアプリケーションがあります。
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
私はすべてのPOを試し私は見つけることができたが、何も助けなかった。
信頼性の高いセッションを有効にするには、いくつかのアドバイスが、(カスタムバインディングを持っている場合のみ)、それはSSLでは動作しません、他の人のアドバイスは、HTTP代わりのHTTPSを使用するには、私は思います可能なら現在の設定でセッションを有効にすることができます。
これを達成する方法はありますか?
どんな種類のヘルプでも大歓迎です。
wcfサービスでセッション状態を有効にする理由は何ですか?あなたが高いパフォーマンスを求めているなら、これはボトルネックになる可能性があります。セッション状態wcfサービスは避けるべきです。 –
すべてのセッションに_user変数が必要です。すべての呼び出しに対してサービスクラスの新しいインスタンスが取得されます。 _userの値は常にNothingです。 – hgulyan
すべてのクライアントのデータを保存する必要がある場合、私の状況にはどのような解決方法を使用しますか? – hgulyan