有两种方式添加服务引用,以了解服务:
Discover
按钮:搜索在当前解决方案的项目。
Go
按钮:连接到地址框中的服务并检索元数据。
在点击Go
之前,您需要确实已经有服务在运行。
编辑
我只是从你的截图,你试图连接到一个URL的net.tcp注意到。我认为在MEX上使用http更常见。你的app.config看起来是这样的:
<services>
<service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"
name="WcfServiceLibrary1.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="WcfServiceLibrary1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/Service1" />
<add baseAddress="http://localhost:8524/Service1" />
</baseAddresses>
</host>
</service>
</services>
注意的HTTP基地址不同的端口号。然后,您可以在“添加服务参考”工具中使用“http:// localhost:8524/Service1”。您还应该能够使用您的网络浏览器连接到它。
允许通过HTTP GET(例如从浏览器)元数据交换,还需要通过行为来启用它:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
我不知道,如果添加服务引用工具在乎这些。即使您不想允许http获取访问(httpGetEnabled =“False”),您仍然需要包含此行为以启用MEX(除非您以编程方式添加它)。
尝试添加服务引用时是否运行该服务? – 2012-04-17 15:13:28
是的,如上所述,我已经完成了本教程中解释的所有工作,其中包括启动服务。 – 2012-04-17 16:07:08
没错,但是当你尝试从你的新客户端添加服务引用时,你是否有实际运行的服务? – 2012-04-17 16:09:52