我有一个 WCF 服务,我通过将其接口复制到示例客户端项目来进行测试。
现在我想通过添加服务引用来正常工作。
该服务托管在 Windows 托管中(使用installUtil
)。
该服务有 2 个项目 - 外部(接口 + 数据合同)和内部(实现)。
由于某种原因,它没有 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
引用我的服务?我希望该服务是 Windows 托管的,我不想和我一起拖动 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