添加WCF服务引用出错:content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.


下载“http://127.0.0.1:960/Service.svc”时出错。

请求因 HTTP 状态 404 失败: Not Found。

元数据包含无法解析的引用:“http://127.0.0.1:960/Service.svc”。

没有终结点在侦听可以接受消息的 http://127.0.0.1:960/Service.svc。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参见 InnerException 以了解详细信息。
远程服务器返回错误: (404) 未找到。
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
浏览器访问服务显示

解决方案:
在配置文件中添加
 <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <!--<behavior name="GeoDataBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>-->
      </serviceBehaviors>
      <!--<endpointBehaviors>
        <behavior name="GDEPBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>-->
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="SerViceBinding" crossDomainScriptAccessEnabled="true"/>
      </webHttpBinding>
      
    </bindings>
     
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>

  </system.serviceModel>

再次在浏览器中放问服务地址,出现以下界面,即可成功添加服务引用

长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn