0
我得到以下錯誤:端點是否爲空?
The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified
但我對客戶終端的ADRESS,這到底是怎麼回事呢?
代碼:
ChannelFactory<CommService.ITwService> myChannelFactory
= new ChannelFactory<CommService.ITwService>();
CommService.ITwService wcfClient1 = myChannelFactory.CreateChannel();
客戶:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/CommService/Service1/"
binding="wsHttpBinding" contract="CommService.ITwService"
name="Super">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services />
<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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
服務器:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/CommService/Service1/"
binding="wsHttpBinding" bindingConfiguration="" contract="CommService.ITwService"
name="" kind="" endpointConfiguration="">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
</client>
<services>
<service name="CommService.Service1">
<endpoint address="SuperEndPoint" binding="wsHttpBinding" name="SuperEndPoint"
contract="CommService.ITwService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/CommService/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
您是否嘗試過ChannelFactory的其他重載?在其中給出EndPoint或endPointConfigurationName。 – 2012-01-09 08:32:07
@Amar現在我做了。它不會從我的app.config中讀取。 – Nahum 2012-01-09 08:37:02
你想從配置文件中讀取配置嗎?你的陳述並不令人困惑。反正你看起來像你的Win Form或控制檯應用程序作爲你的服務客戶端。 .config文件應該位於.exe所在的位置,其次,.config文件的名稱應該與.exe文件的名稱相同。如果我在正確的軌道上,Plz讓我知道。 – 2012-01-09 08:44:03