Добрый день, подскажите в чем проблема. Хочу чтобы сервис работал в режиме
PerSession, но выдает ошибку:
"Контракту требуется свойство Session, однако приявязка BasicHttpBinding_IServiceTransportModule его не поддерживает или этого не позволяет неправильная настройка."
Добавил данные настройки в интерфейс
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IServiceTransportModule
{ [OperationContract]
bool ValidateAddress(string emailAddress);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class TModuleServ : IServiceTransportModule
{ public bool ValidateAddress(string emailAddress)
{
string pattern = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
return Regex.IsMatch(emailAddress, pattern);
}
}
Конфиг сервиса:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<identity impersonate="false"/>
<compilation debug="true" />
<httpRuntime maxRequestLength="2147483647"
executionTimeout="01:00:00"/>
</system.web>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="false"
logMessagesAtTransportLevel="true"
maxMessagesToLog="2147483647"
maxSizeOfMessageToLog="2147483647" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServiceTransportModule" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TransportModuleServiceBehavior"
name="TransportModuleService.TModuleServ">
<endpoint address="http://localhost:8080/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IServiceTransportModule"
name="LOC" bindingName="BasicHttpBinding_IServiceTransportModule"
contract="TransportModuleService.IServiceTransportModule">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8080/mex" binding="mexHttpBinding" name="MM" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/" />
</baseAddresses>
<timeouts closeTimeout="01:10:10" openTimeout="01:00:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TransportModuleServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>