WCF ws2007HttpBinding サービスからデータを取得しようとしていますが、実行するたびに次のエラーが発生します。
Content Type application/soap+xml; charset=utf-8 was not supported by service
http://localhost/GoldInSacks.MutualFunds.local/MutualFunds.svc. The client
and service bindings may be mismatched.
InnerException はこれを読み取ります。
The remote server returned an error: (415) Cannot process the message because
the content type 'application/soap+xml; charset=utf-8' was not the expected
type 'text/xml; charset=utf-8'..
web.config の system.ServiceModel セクションは次のようになります。
<system.serviceModel>
<services>
<service name="GoldInSacks.MutualFunds">
<endpoint address=""
binding="ws2007HttpBinding"
contract="GoldInSacks.MutualFunds.Local.IMutualFunds" />
</service>
</services>
<bindings>
<ws2007HttpBinding>
<binding>
<security mode="None" />
</binding>
</ws2007HttpBinding>
</bindings>
</system.serviceModel>
コンソール アプリケーションで現在実行されているクライアント コードは次のようになります。
EndpointAddress address =
new EndpointAddress("http://localhost/MutualFunds.local/MutualFunds.svc");
var binding = new WS2007HttpBinding();
binding.Security.Mode = SecurityMode.None;
ChannelFactory<IMutualFundsChannel> channelFactory =
new ChannelFactory<IMutualFundsChannel>(binding, address);
IMutualFundsChannel channel = channelFactory.CreateChannel();
var mf = channel.GetMutualFundsByCustomer(1);
channel.Close();
foreach (var m in mf)
{
System.Console.WriteLine(m.Name);
}
System.Console.ReadLine();
GetMutualFundsByCustomer の呼び出しでエラーが発生します。
wsHttpBinding も試しましたが、同じエラーが発生しました。
これを機能させる方法を知っている人はいますか?
(この質問が簡潔で申し訳ありませんが、遅くなり、睡眠が必要です)。