2014-11-14 26 views
0

我對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(); 
} 
+1

從來沒有見過這種行爲,但後來我總是做自己的配置,通常做自我託管的服務。似乎有點奇怪,它會在客戶端創建兩個端點,還有兩個具有不同安全模式的綁定,代碼在服務端看起來如何? – Jontatas 2014-11-14 12:54:07

+0

該代碼是非常標準的,我會發布界面,以免混淆實際的代碼(這不是真的有關) – Ben 2014-11-14 13:08:40

回答

0

好的,多虧了Jontatas提到端點具有獨立綁定類型的事實,它讓我思考。

原來我忘記從IIS本身刪除http綁定(未使用)。從IIS中刪除該綁定也會刪除生成的配置中的不正確綁定。

+0

很高興你得到它的工作! – Jontatas 2014-11-17 12:31:00

相關問題