Web プロジェクトとクラス ライブラリ プロジェクトで構成されるソリューションがあります。Web プロジェクト ソリューションは、wcf サービスを直接参照します。2 つ目の wcf サービスがありますが、それを直接参照するのはクラス ライブラリ プロジェクトです。Web プロジェクトへの参照としてクラス ライブラリ (出力) を追加しています。
したがって、私の Web プロジェクトの web.config には、2 つの scf サービスが構成されています。app.config (system.serviceModel 部分) を直接 web.config に手動でコピーし、別の wcf サービスと (dll を介さずに直接) 対話するように Web プロジェクトを構成したため、このプロセスは簡単でした。
私の Web プロジェクトは、3 番目の Web サービス (asmx) と通信する必要があります。ここでも、これをクラス ライブラリとして使用し、dll を Web プロジェクトに含める予定です。(これは別の解決策です)。この特定のクラス lib プロジェクトの app.config を調べたとき、必要なセクションをコピーして、現在の web.config とマージするだけだと思いました。
そのため、3 番目のクラスの lib プロジェクト (asmx サービスを参照する) の場合、バインディング ノードの下に、basicHttpBinding というノードがあり、次に customBinding があることに気付きました。さらにクライアント ノードの下には、サービス属性を持つ 2 つのエンドポイント ノードがありました。(まず、ここに 2 つのエンドポイントが必要な理由がわかりません)。
そこで、バインディング ノードの下にあるものを (3 番目のクラスの lib prj app.config から) コピーし、それをバインディング ノード (web.config 内) に追加しました。エンドポイントをコピーするためにも同様のプロセスを実行しました。しかし、Web サイトを実行しようとすると、SOAP クライアント (asmx サービス) の初期化時に停止する例外が発生します。
asmx Web サービスを追加する前の web.config は次のようになります。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IEmployeeService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
<binding name="WSHttpBinding_IHelper" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8731/Design_Time_Addresses/InfiniumIS/EmployeeService/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEmployeeService"
contract="InfiniumWS.IEmployeeService" name="WSHttpBinding_IEmployeeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/SQLIS/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHelper"
contract="SQLIS.IHelper" name="WSHttpBinding_IHelper">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
以下は、asmx サービスを使用したプロジェクトのサービス モデルです (app.config から取得)。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ServiceSoap1" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="ServiceSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://is.security/WebAppSec_WS/service.asmx"
binding="basicHttpBinding" bindingConfiguration="ServiceSoap"
contract="apps.intranet.ws.ServiceSoap" name="ServiceSoap" />
<endpoint address="https://is.security/WebAppSec_WS/service.asmx"
binding="customBinding" bindingConfiguration="ServiceSoap12"
contract="apps.intranet.ws.ServiceSoap" name="ServiceSoap12" />
</client>
</system.serviceModel>
単純にセクションをマージしました。つまり、バインディング ノードの下の 2 番目の構成に含まれるものをすべてコピーし、それを 1 番目の構成に追加しました。エンドポイントをコピーするために同様のプロセスを実行しました。
ps: 2 番目の構成 (asmx) で 2 つのエンドポイントが表示される理由がわかりません。