インターフェイスをサンプルクライアントプロジェクトにコピーしてテストした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
、それでも同じエラーが発生します。