Web services 添加<;行为名称=”;myConfiguration“&燃气轮机;抛出UTF错误-WCF

Web services 添加<;行为名称=”;myConfiguration“&燃气轮机;抛出UTF错误-WCF,web-services,wcf,utf-8,web-config,Web Services,Wcf,Utf 8,Web Config,我正在尝试连接我的一个方法,以便在get请求发送到适当的端点后调用它。当篡改我的web.config时,我为我的行为指定了一个名称,并出现以下错误 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. 不确定为什么只为我的行为指定一个属性会引发此错误 <system.serviceModel> <services> <

我正在尝试连接我的一个方法,以便在get请求发送到适当的端点后调用它。当篡改我的web.config时,我为我的行为指定了一个名称,并出现以下错误

'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
不确定为什么只为我的行为指定一个属性会引发此错误

<system.serviceModel>
    <services>
      <service name="Developer1.Core.Service.Developer1Service"
           bindingConfiguration="myConfiguration"     >
        <endpoint
            address="" behaviorConfiguration="webBehavior"
            binding="webHttpBinding"
            contract="Developer1.Core.ServiceContracts.IDeveloper1Service" />
        <endpoint
            address="mex" binding="mexHttpBinding"
            contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="myConfiguration">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
            multipleSiteBindingsEnabled="true" />
  </system.serviceModel>


与应用程序配置一起使用。然后,我的WCF应用程序从我的库中的服务文件继承,并且不包含任何额外的服务方法,它只是在我的WCF库中运行这些方法。但是这个库是用来处理HTTP请求的。可能不是正确的解决方案,但它对我有效。

您将myConfiguration定义为服务的bindingConfiguration。但您根本没有绑定配置。您使用此名称定义了服务行为。它与绑定无关。

所显示的代码/配置中没有任何问题。你能告诉我们请求/客户端的详细信息吗?我有理由怀疑,因为你有基于Rest的
webHttpBinding
。不知何故,您的客户端正在向
Rest
端点发送
Soap
消息。错误消息说明了一切。但是有许多文章展示了如何在wcf服务中使用某些方法使REST工作。我配置错了吗?你能详细说明一下吗?本文展示了如何使REST与wcf应用程序一起工作,我遵循了相同的步骤。一旦我将name属性添加到行为中。错误发生了。感谢您的回复。我解决了这个问题,似乎我必须在服务库而不是应用程序中执行我正在执行的操作。所以现在我用我的wcf库处理REST,其他方法在我的wcf应用程序中处理。似乎应用程序配置和web配置在某种程度上有所不同。然后我转到解决方案属性并选择一次启动多个项目。现在,我可以在库中使用get请求命中方法,应用程序运行所有其他不处理HTTP协议的方法