【问题标题】:I am getting error 404 on run WCF services. web-services don't work on live Server我在运行 WCF 服务时收到错误 404。网络服务在实时服务器上不起作用
【发布时间】:2019-09-29 00:46:47
【问题描述】:

我在 Win8 上使用 VS2013 创建了 WCF 服务。如果我通过 VS (localhost:port) 启动服务,我可以在 json 中进行 GET 响应

但我在服务器 (IIS7) 上托管相同的服务,然后我得到 404 错误

本地地址:http://localhost:43596/abc.svc/LoginUser/abc/abc

直播网址:http://mywwebsite.com:80/abc.svc/LoginUser/abc/abc

【问题讨论】:

  • 请发布您的 Web.config
  • HTTP 404 Not Found Error 表示在服务器上找不到您尝试访问的网页。归根结底就是服务器设置不正确,找不到WCF服务的路由。
  • @betelgeuce 建议我关于 wcf 服务的服务器配置

标签: c# asp.net web-services wcf iis-7


【解决方案1】:

在我看来,托管环境可能有问题,请尝试在 IIS 中启用 WCF 功能支持。


这是我的服务,希望对您有用。
IService1.cs

[ServiceContract]
public interface IService1
{

    [OperationContract]
    [WebGet]
    string GetData(int value);

Service1.svc.

public class Service1 : IService1
{
    public string GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }

Web.config

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="mybinding">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="webHttpBinding" scheme="http"/>
      <add binding="webHttpBinding" scheme="https" bindingConfiguration="mybinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

由于上述配置同时支持http和https协议,我们需要在IIS站点绑定模块中添加http和https绑定。


参考。
How to make WCF Service Use HTTPS protocol
如果有什么我可以帮忙的,请随时告诉我。

【讨论】:

    猜你喜欢
    • 2019-03-19
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多