当我尝试从客户端应用程序调用WCF时获取协议异常

时间:2013-06-06 12:45:11

标签: c# asp.net wcf

我收到异常错误消息:

Content Type text/xml; charset=utf-8 was not supported by service 
http://localhost:8000/GettingStarted/CalculatorService/.  
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_ICalculator" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8000/GettingStarted/CalculatorService/"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICalculator"
            contract="Calculatorservice.ICalculator"  name="BasicHttpBinding_ICalculator" />
    </client>
</system.serviceModel>
</configuration>

我的服务app.config是

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<appSettings>
 <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
  <service name="GettingStartedLib.CalculatorService">
    <host>
      <baseAddresses>
        <add baseAddress = "http://localhost:8000/GettingStarted/CalculatorService/" />
      </baseAddresses>
    </host>
   <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.ICalculator">
     <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
     <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
  </behaviors>
  </system.serviceModel>
  </configuration>

我是WCF服务的新手。我完全糊涂了,我无法弄清楚我哪里出错了。 我还没有在我的IIS中托管wcf服务。能够在wcf主机应用程序运行后成功浏览(控制台应用程序运行服务)

0 个答案:

没有答案