繁体   English   中英

WCF错误调用Ws2007HttpBinding

[英]WCF error calling Ws2007HttpBinding

我正在尝试从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,但它给出了相同的错误。

有人知道如何进行这项工作吗?

(对于这个问题的简短性,我深表歉意,但是已经晚了,我需要睡觉)。

您是否在客户端和服务端使用相同的SOAP版本? 也许相关? http://social.msdn.microsoft.com/Forums/zh-CN/wcf/thread/f29cd9c8-3c89-43d2-92ae-d2a270ab86b9/

干杯-乔克

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM