私の WCF サービスの 1 つには、大きなサイズのファイルをパラメーターとして受け取る操作コントラクトがあります。したがって、クライアントがこれを送信しようとすると、例外が発生し、サーバー トレースを確認すると、次のように表示されました。
メッセージ: 受信メッセージの最大メッセージ サイズ クォータ (65536) を超えました。クォータを増やすには、適切なバインド要素で MaxReceivedMessageSize プロパティを使用します。
WCF サービスのデフォルトの簡略化された構成を使用していたため、次のように新しいサービス定義を追加しました。
<system.serviceModel>
<services>
<service name="MyNamespace.MyService">
<endpoint address="MyService.svc"
binding="basicHttpBinding" bindingConfiguration="basicHttp"
contract="MyNamespace.IMyService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="10485760"
maxBufferSize="10485760"
maxBufferPoolSize="10485760">
<readerQuotas maxDepth="32"
maxArrayLength="10485760"
maxStringContentLength="10485760"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
...
</behaviors>
<protocolMapping>
...
</protocolMapping>
サービスを利用する方法は、ヘルパー クラスにチャネルを返す関数があり、そのチャネルを使用して操作を呼び出すことです。
public static T CreateChannel<T>() where T : IBaseService
{
System.ServiceModel.BasicHttpBinding binding= new System.ServiceModel.BasicHttpBinding();
binding.TransferMode = TransferMode.Streamed;
binding.Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.None };
binding.MaxReceivedMessageSize = 10485760;
binding.MaxBufferSize = 10485760;
System.ServiceModel.ChannelFactory<T> cf2 = new ChannelFactory<T>(binding,
new System.ServiceModel.EndpointAddress(MyEndpointAddress)); //I checked this part, the address is correct.
T Channel= cf2.CreateChannel();
return Channel;
}
その後、
var businessObject = WcfHelper.CreateChannel<IMyService>();
var operationResult = await businessObject.MyOperationAsync(...);
他のサービスは正しく実行されていますが、構成で定義したサービスは、「エンドポイントがリッスンしていません...」という例外を明示的に返します。IISExpress を使用して VS2012 で開発しています。何が問題なのですか、何か提案はありますか?