zoukankan      html  css  js  c++  java
  • WCF Http Get 方法返回 400 Bad Request Kevin

    原因在于没有设置WFC支持Http行为

    解决方法是将webconfig文件改成下面的格式:

    <?xml version="1.0"?>
    <configuration>
    
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <protocolMapping>
          <add scheme="http" binding="webHttpBinding"/>
        </protocolMapping>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
    
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior>
              <webHttp/>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>  
     </configuration>

    关键在

    <system.serviceModel>
        <protocolMapping>
            <add scheme="http" binding="webHttpBinding"/>
        </protocolMapping>
        <behaviors>
    
    <system.serviceModel>

    <system.serviceModel>
        -----
        </protocolMapping>
        <behaviors>
            <endpointBehaviors>
                <behavior>
                    <webHttp />
                </behavior >
            </endpointBehaviors>
        <behaviors>
        ------
    <system.serviceModel> 

    参考来源:stackoverflow

  • 相关阅读:
    myeclipse 代码提示(alt+/)
    彻底解决mysql中文乱码
    Pycharm取消默认的右击运行unittest方法
    解决Ubuntu的root账号无法登录SSH问题-Permission denied, please try again.
    language support图标在哪里?怎么消失了?
    Ubuntu安装谷歌输入法或者搜狗
    最大流算法-ISAP
    WC2013-糖果公园
    bzoj4032-最短不公共子串
    bzoj1031-字符加密
  • 原文地址:https://www.cnblogs.com/kfx2007/p/2998098.html
Copyright © 2011-2022 走看看