我有我测试通过复制其接口为样本客户端项目的WCF服务。
现在我想通过添加服务引用正常工作。
该服务在托管(使用Windows托管installUtil
)。
该服务具有2个项目 - 的外部(接口+ datacontracts)和内部部件(实现)。
出于某种原因,它没有一个app.config所以我手动添加一个:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ExecutionService" behaviorConfiguration="Default">
<endpoint name="TCPEndpoint" address="" binding ="netTcpBinding" contract="Externals.IExecutionService"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:3040/ExecutionService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
试图从我的样本客户端添加服务引用导致以下错误:
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:3040/ExecutionService/Externals.IExecutionService'.
There was no endpoint listening at net.tcp://localhost:3040/ExecutionService/Externals.IExecutionService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
If the service is defined in the current solution, try building the solution and adding the service reference again.
我看到这里有在app.config中没有必要。
我有点困惑,我与一个初学者WCF
。
一个很好的如何WPF
应用程序可以引用我的服务? 我希望该服务被托管的窗口,我不想跟我拖的DLL。
编辑
我添加元数据终结和我的AppConfig现在看起来是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ExecutionService" behaviorConfiguration="Default">
<endpoint name="TCPEndpoint"
address=""
binding ="netTcpBinding"
contract="Externals.IExecutionService"/>
<endpoint address="mex"
binding="maxHttpBinding"
contract="Externals.IExecutionService"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:3040/ExecutionService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我试图通过使用添加服务参考net.tcp://localhost:3040/ExecutionService
, net.tcp://localhost:3040/ExecutionService/Externals
和net.tcp://localhost:3040/ExecutionService/Externals/IExecutionService
和我仍然得到同样的错误。