添加WCF服务引用时总是出错,请高手指点。

xys1995 2008-11-21 10:38:39
首先写了一个Service,然后编译一下,再在Debug文件夹中运行,然后在客户端的程序中添加服务引用,提示以下错误:

元数据包含无法解析的引用:“net.tcp://localhost:5351/”。
没有终结点在侦听可以接受消息的 net.tcp://localhost:5351/。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参阅 InnerException 以了解详细信息。如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。


我的服务端配置文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WCFSample.CalculatorService" behaviorConfiguration="serbe">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5351" />
</baseAddresses>
</host>
<endpoint address="net" binding="netTcpBinding" bindingConfiguration="bd" contract="WCFSample.ICalculator" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="bd">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serbe">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
...全文
3449 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangxiao100200 2012-01-09
  • 打赏
  • 举报
回复
这个我需要呀
liuyuainil 2012-01-04
  • 打赏
  • 举报
回复
TCP呢 ? 那个只是Http的
nkhuangyanping 2010-11-20
  • 打赏
  • 举报
回复
我添加了,但是我还是有这个问题,不知怎么回事?
b3727180 2010-11-18
  • 打赏
  • 举报
回复
1dddddddddddddddddddddddddd
fengpo_1 2010-10-25
  • 打赏
  • 举报
回复
看下答案
s8975565 2010-08-24
  • 打赏
  • 举报
回复
10fen10分
shuyuhello 2010-03-26
  • 打赏
  • 举报
回复
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
vallen330 2010-01-11
  • 打赏
  • 举报
回复
aa
xys1995 2008-11-24
  • 打赏
  • 举报
回复
谢谢acqy ,按照你的方法问题解决。
acqy 2008-11-21
  • 打赏
  • 举报
回复
你参考系统自动生成的config文件:

<system.serviceModel>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<!-- 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>


其中:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
这一行就是添加metadata endpoint的。你可以参考,当然,也要记得相应的配置behavior。

之后启动服务,成功以后,再在客户端添加服务引用。
acqy 2008-11-21
  • 打赏
  • 举报
回复
你服务器端的配置中没有添加Metadata Endpoint的Binding。这个Binding对于客户端添加引用是必须的,但是一旦添加以后,你可以去掉这个Binding。

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧