1

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 も試しましたが、同じエラーが発生しました。

これを機能させる方法を知っている人はいますか?

(この質問が簡潔で申し訳ありませんが、遅くなり、睡眠が必要です)。

4

1 に答える 1

1

クライアント側とサービス側で同じSOAPバージョンを使用していますか?おそらく関連していますか? http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/f29cd9c8-3c89-43d2-92ae-d2a270ab86b9/

乾杯-ジョッケ

于 2012-06-05T08:55:07.867 に答える