一直在尝试向我的自托管服务添加一个非安全端点,所以基本上我有一个使用会话的接口和另一个不使用会话的接口。它们都由同一个类实现。这是我的服务器配置文件的一部分:
<service name="PT.DataServices.WCFService.PTDataServices" behaviorConfiguration="dataServiceBehavior">
<endpoint address="PTDataServices" binding="wsHttpBinding" contract="PT.DataServices.WCFService.IPTDataServices" bindingConfiguration="wsHttpBinding1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="PTDataServicesNoSessions" binding="wsHttpBinding" contract="PT.DataServices.WCFService.IPTDataServicesNoSessions" bindingConfiguration="wsHttpBinding2">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://*/PT6/DataServices/"/>
</baseAddresses>
</host>
</service>
没有会话的界面:
[ServiceContract(
SessionMode = SessionMode.NotAllowed
)]
public interface IPTDataServicesNoSessions
{
[OperationContract]
string GetData(int value);
}
与会话的接口:
[ServiceContract(
SessionMode=SessionMode.Required
)]
public interface IPTDataServices
{
[OperationContract(IsInitiating = true, IsTerminating = false)]
DcUser InitSession(string userCode, string passwordEncrypted, string connectionString);
[OperationContract(IsInitiating = false, IsTerminating = true)]
int EndSession();
[OperationContract(IsInitiating = false, IsTerminating = false)]
string GetData(int value);
}
在浏览器中输入 :http://localhost/PT6/DataServices/ 会返回:
PT.DataServices.WCFService.IPTDataServicesNoSessions.GetData 操作引用已从 PT.DataServices.WCFService.IPTDataServices.GetData 操作导出的消息元素 [http://tempuri.org/:GetData]。
我不想根据动态使用的端点更改所有客户端以使用不同的方法名称......我如何告诉 WCF 在 2 个接口中的每个接口上使用相同的方法是可以的?