zoukankan      html  css  js  c++  java
  • WCF 在VS中,添加服务引用,地址输入http://ip/Service.svc,点击前往,提示错误,内容如下:

    WCF的service端的webconfig如下:

    <?xml version="1.0"?>
    <configuration>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
        <services>
          <service behaviorConfiguration="ServiceBehavior"
                   name="WcfServiceLibrary1.Service1">
            <endpoint binding="wsHttpBinding"
                      bindingConfiguration=""
                      contract="WcfServiceLibrary1.IService1"/>
          </service>
        </services>
      </system.serviceModel>
    </configuration>

    WCF 在VS中,添加服务引用,地址输入http://ip/Service.svc,点击前往,提示错误,内容如下:

    下载“http://127.0.0.1:7293/WCFServerRefWCFLib.svc”时出错。
    请求因 HTTP 状态 404 失败: Not Found。
    元数据包含无法解析的引用:“http://127.0.0.1:7293/WCFServerRefWCFLib.svc”。
    没有终结点在侦听可以接受消息的 http://127.0.0.1:7293/WCFServerRefWCFLib.svc。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参见 InnerException 以了解详细信息。
    远程服务器返回错误: (404) 未找到。
    如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
    

      

    解决方法是:

    在<system.serviceModel>节点中添加:

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

    最后的配置是:

    <?xml version="1.0"?>
    <configuration>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
        <services>
          <service behaviorConfiguration="ServiceBehavior"
                   name="WcfServiceLibrary1.Service1">
            <endpoint binding="wsHttpBinding"
                      bindingConfiguration=""
                      contract="WcfServiceLibrary1.IService1"/>
          </service>
        </services>
      </system.serviceModel>
    </configuration>
  • 相关阅读:
    Mac Pro 安装 Sublime Text 2.0.2,个性化设置,主题 和 插件 收藏
    Mac Pro 编译安装 Nginx 1.8.1
    Mac Pro 解压安装MySQL二进制分发版 mysql-5.6.30-osx10.11-x86_64.tar.gz(不是dmg的)
    Mac Pro 修改主机名
    Mac Pro 软件安装/个性化配置 汇总
    Mac Pro 安装 Homebrew 软件包管理工具
    Mac Pro 使用 ll、la、l等ls的别名命令
    Mac Pro 入门、遇到的问题、个性化设置 汇总
    Linux/UNIX线程(2)
    工作流引擎activiti入门
  • 原文地址:https://www.cnblogs.com/easy5weikai/p/3340960.html
Copyright © 2011-2022 走看看