简体   繁体   English

WCF错误调用Ws2007HttpBinding

[英]WCF error calling Ws2007HttpBinding

I am trying to get data from a WCF ws2007HttpBinding service but I am getting the following error every time I run it: 我正在尝试从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.

The InnerException reads this: 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'..

The system.ServiceModel section of the web.config looks like this: 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>

and the client code which is currently running in a console application looks like this: 当前正在控制台应用程序中运行的客户端代码如下所示:

        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();

The error occurs on the call to GetMutualFundsByCustomer. 调用GetMutualFundsByCustomer时发生错误。

I did try wsHttpBinding as well but it gave the same error. 我也尝试过wsHttpBinding,但它给出了相同的错误。

Does anybody know how to make this work? 有人知道如何进行这项工作吗?

(I apologize for the terseness of this question but it's late and I need sleep). (对于这个问题的简短性,我深表歉意,但是已经晚了,我需要睡觉)。

Are you using the same SOAP version on client and service side? 您是否在客户端和服务端使用相同的SOAP版本? Perhaps related? 也许相关? http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/f29cd9c8-3c89-43d2-92ae-d2a270ab86b9/ http://social.msdn.microsoft.com/Forums/zh-CN/wcf/thread/f29cd9c8-3c89-43d2-92ae-d2a270ab86b9/

Cheers --Jocke 干杯-乔克

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

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