更改端点时客户端和服务绑定可能不匹配

时间:2013-09-09 12:04:27

标签: c# wcf service

我有一个可以正常工作的WCF服务,如果我不尝试配置端点地址。在我尝试编辑端点时,就像这样:

WSHttpBinding binding = new WSHttpBinding();
EndpointAddress endpoint = new EndpointAddress(new Uri("http://corne-pc:8733/Design_Time_Addresses/Magenta/Service1/"));
MaciService.I_MaciWcfServiceClient maci = new MaciService.I_MaciWcfServiceClient(binding, endpoint);
MessageBox.Show(maci.GetUserCount_Single("192.168.1.212", "11010").ToString());

调用服务时出现以下错误消息:

Content Type application/soap+xml; charset=utf-8 was not supported by service
http://corne-pc:8733/Design_Time-Addresses/Magenta/Service1. The client and
service bindings may be mismatched.

我发现了一些类似的帖子,无法解决我的问题。例如,我不认为它可能是肥皂不匹配,因为它在不改变端点时起作用。

这是我的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_I_MaciWcfService" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://corne-pc:8733/Design_Time_Addresses/Magenta/Service1/"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_I_MaciWcfService"
            contract="MaciService.I_MaciWcfService" name="BasicHttpBinding_I_MaciWcfService" />
    </client>
</system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:3)

您需要确保您的客户端和服务器配置使用相同的绑定。我相信一个人正在使用WSHttp和一个BasicHttp。这与错误一致,这意味着客户端正在发送SOAP12,但服务器需要SOAP11。