2010-05-19 131 views
0

我在服務器B上有一個WCF服務。然後在機器A上是客戶端,這是一個Windows服務。在單獨的dll中包含了該服務的所有業務邏輯。所以我的代理WCF就在這邊。我有2個app.config(僅客戶端):1爲服務和另一個在DLL中。所以我試着(爲了測試目的)把servicemodel配置部分放在兩者中。兩個仍然,它不工作,它說,它無法找到該名稱和該合同的端點...WCF找不到客戶端配置

我想在這裏做的是修改編程的配置。下面是在業務層DLL的代碼:

Dim ep As New EndpointAddress(New Uri(ConfigurationManager.AppSettings(nomServeurCible)), _ 
            EndpointIdentity.CreateDnsIdentity(ConfigurationManager.AppSettings("Identity_" & nomServeurCible))) 

    serviceCible = New ServiceProxy.ExecOperClient("wsHttp", ep) 

這裏是配置文件的樣本:

<add key="TEST1" value="http://TEST1:8000/MySpacePerso/ExecOperService"/> 
<add key="TEST1_CertificateSerialNumber" value="10 hj 6y 7b 00 01 32 12 01 21"/> 
<add key="Identity_TEST1" value="TEST1"/> 

<system.serviceModel> 
<client> 
    <endpoint address="http://SERV_NAME:8000/CSSTQDA/ExecOperService" binding="wsHttpBinding" 
      behaviorConfiguration="myClientBehavior" 
      bindingConfiguration="MybindingCon" contract="ExecOper.Service.IExecOper" 
      name="wsHttp"> 
    <identity> 
     <dns value="SERV_CERT_NAME"/> 
    </identity> 
    </endpoint> 
</client> 
<bindings> 
    <wsHttpBinding> 
    <binding name="MybindingCon"> 
     <security mode="Message"> 
     <message clientCredentialType="UserName" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceTraitementBehavior"> 
     <serviceMetadata httpGetEnabled="True"/> 
     <serviceDebug includeExceptionDetailInFaults="True" /> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <behavior name="myClientBehavior"> 
     <clientCredentials> 
     <serviceCertificate> 
      <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/> 
     </serviceCertificate> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 

回答

0

嗯,事實證明這只是一個ConfigurationName的事標籤在我的代理類...對不起:-)它沒有我的合同正確的命名空間。完全限定名稱必須與app.config中的名稱匹配。