これは、wcf ライブラリ プロジェクトがどのようにホストされているかについての私の理解です。wcf ライブラリ プロジェクトを作成すると、app.config は次のようになります。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfLib.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfLib/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="wsHttpBinding" contract="WcfLib.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>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
</configuration>
単純に空のコンソール アプリケーション プロジェクトを作成し (その中に a を入れるだけConsole.ReadLine()
)、前のプロジェクトのアセンブリへの参照を追加し、services
上記のようにタグ全体を追加することができます。現在、ホストされています。そのコンソール アプリケーションが存続する限り存続します。
この作業を行うためにマークアップがどのように書かれたかのパターンに注意してください。のすべては、<services/>
ホストされる wcf サービス エンティティを表します。この場合、ホスティングは、コンソール アプリケーションを介した構成によって行われました。
私は、wcf サービスの消費について同様の例えに従うことができるかどうかを調べています。同じ構成パターンを使用して自分の wcf クライアントを作成できますか? 最終的に、これらの構成を別の構成ファイルに入れることを検討しています。