HTML 文档不包含 Web 服务发现信息。

元数据包含无法解析的引用:“http://localhost:1399/WCF-Service/Service.svc”。
服务 http://localhost:1399/WCF-Service/Service.svc 不支持内容类型 application/soap+xml; charset=utf-8。客户端和服务绑定可能不匹配。
远程服务器返回错误: (415) Unsupported Media Type。
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。

===========================

解决办法

Web.config文件中要有如下配置:

<system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      <!-- WCF服务新增节点-->
        <services>
          <service behaviorConfiguration="ServiceBehavior" name="Service">
            <endpoint address="" binding="basicHttpBinding" contract="IService">
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
    </system.serviceModel>

在service节点中增加behaviorConfiguration属性,并命名ServiceBehavior,然后在behavior节点中指定name为ServiceBehavior(默认为空)

posted on 2014-04-15 14:54  schyu  阅读(421)  评论(0编辑  收藏  举报