我對WCF並不是很有經驗,因此我有點卡住了這個,我允許我的WCF服務配置它自己的端點(我的手動嘗試已經不到成功)。現在,從一個問題可以看出,它使用本地計算機名稱和本地Windows域添加了第二個端點。WCF使用計算機名稱和本地域名添加第二端點
我的配置文件是這樣的:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
然而,當添加該WCF到WPF應用程序,它生成以下配置(地址改變爲安全)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAdminService">
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
<binding name="BasicHttpsBinding_IAdminService">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://machinename.domain.local/PortalServices/AdminService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAdminService"
contract="AdminService.IAdminService" name="BasicHttpBinding_IAdminService" />
<endpoint address="https://mysite.co.uk/PortalServices/AdminService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_IAdminService"
contract="AdminService.IAdminService" name="BasicHttpsBinding_IAdminService" />
</client>
</system.serviceModel>
正如你所看到的,它增加了一個有效的URL和一個本地域的URL
http://machinename.domain.local/PortalServices/AdminService.svc
我該如何防止被添加?因爲在每次部署/服務更新後,必須記住手動刪除它,這有點痛苦。
As請求,這是接口類之一。
[ServiceContract]
public interface IAdminService
{
[OperationContract]
List<PortalApp> GetApplications();
[OperationContract]
int AddApplication(string AppName, string Desc, string version, bool enabled);
[OperationContract]
bool EditApplication(int appid, string AppName, string Desc, string version, bool enabled);
[OperationContract]
bool AddAppAccess(int appid, Int16 uid);
[OperationContract]
bool RemAppAccess(int appid, Int16 uid);
[OperationContract]
List<PortalUser> GetUsers();
}
從來沒有見過這種行爲,但後來我總是做自己的配置,通常做自我託管的服務。似乎有點奇怪,它會在客戶端創建兩個端點,還有兩個具有不同安全模式的綁定,代碼在服務端看起來如何? – Jontatas 2014-11-14 12:54:07
該代碼是非常標準的,我會發布界面,以免混淆實際的代碼(這不是真的有關) – Ben 2014-11-14 13:08:40