端点为空?
我收到以下错误:
ChannelFactory.Endpoint 上的 Address 属性为 null。 ChannelFactory 的 Endpoint 必须指定有效的地址
但是我有客户端端点的地址,这里发生了什么?
代码:
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>
I get the following error:
The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified
But I have an adress for the client endpoint, what is going on here?
Code:
ChannelFactory<CommService.ITwService> myChannelFactory
= new ChannelFactory<CommService.ITwService>();
CommService.ITwService wcfClient1 = myChannelFactory.CreateChannel();
Client:
<?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>
Server:
<?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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过创建一个新项目解决了这个问题..创建文件并使用复制粘贴将代码复制到新项目..很奇怪。
solved this by creating a new project.. creating the files and copying the code to the new project using copy paste.. weird.