2011-07-13 40 views
0

我有一個具有多個服務合同的服務,當我運行svcutil.exe時,它只生成一個合同或另一個合同的客戶端代碼(似乎每次運行時都會切換它)。一些更多的信息: 服務:svcutil只爲多個服務合同中的一個生成客戶端代碼

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)] 
public class BackendService : IBackendService, IFitContract 
{ 
    //implementation 
} 

我的web.config看起來像:

<system.web> 
<compilation debug="true" targetFramework="4.0" /> 
</system.web> 
<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
     <serviceMetadata httpGetEnabled="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> 
<bindings> 
    <wsDualHttpBinding/> 
</bindings> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
<protocolMapping> 
    <add scheme="http" binding="wsDualHttpBinding"/> 
</protocolMapping> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 

SvcUtil工具電話:

svcutil.exe /config:App.config /out:BackendService.cs /n:*,BackendServer /r:bin/Debug/CSCommon.dll http://localhost:56725/BackendService.svc?wsdl 

任何想法,爲什麼發生這種情況?

回答

2

由於您沒有爲web.config上的服務聲明任何端點,因此WCF將向其添加一個默認端點。既然你有兩個選擇這個端點,WCF將簡單地選擇1(我不知道它選擇它是什麼)。因此,在這種情況下,您需要明確聲明端點,如下所示。

<system.serviceModel> 
    <services> 
    <service name="BackendServiceNamespace.BackendService"> 
     <endpoint address="ibs" 
       contract="BackendServiceNamespace.IBackendService" 
       binding="wsDualHttpBinding" /> 
     <endpoint address="ifc" 
       contract="BackendServiceNamespace.IFitContract" 
       binding="wsDualHttpBinding" /> 
    </service> 
    </services> 
</system.serviceModel> 
+0

有道理。我認爲協議映射的目的是,我們不需要手動添加端點(在4.0中) –

相關問題