WCF未在IIS 6.0下运行

WCF未在IIS 6.0下运行,wcf,web-services,configuration,iis-6,Wcf,Web Services,Configuration,Iis 6,正在尝试让我的WCF服务在IIS 6下运行 我已根据以下内容创建了.svc和aspnet\u isapi.dll映射: 查看Server1.svc页面时,我得到一个404 我已经用一个简单的.aspx页面测试了该站点,以确保URL正常工作,但是.svc扩展名仍然不正常 我已经安装了.NET3.5SP1,我的web.config正在引用3.5程序集,并且我在查看.aspx页面时没有遇到错误,因此它大概可以很好地拾取这些程序集 有什么问题吗?我能想到两件事: .svc扩展未正确设置(根据您的描述,可

正在尝试让我的WCF服务在IIS 6下运行

我已根据以下内容创建了
.svc
aspnet\u isapi.dll
映射:

查看
Server1.svc
页面时,我得到一个404

我已经用一个简单的.aspx页面测试了该站点,以确保URL正常工作,但是.svc扩展名仍然不正常

我已经安装了.NET3.5SP1,我的
web.config
正在引用3.5程序集,并且我在查看.aspx页面时没有遇到错误,因此它大概可以很好地拾取这些程序集


有什么问题吗?

我能想到两件事:

.svc扩展未正确设置(根据您的描述,可能性最小)。您可以查看此以了解更多详细信息

或者您的网站有多个主机标题。要解决此问题,您必须具有单个主机标头或使用工厂。下面是一个例子:

namespace MyNamespace
{
    public class MultipleHostServiceFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            List<Uri> addresses = new List<Uri>();
            addresses.Add(baseAddresses[0]);
            return base.CreateServiceHost(serviceType, addresses.ToArray());
        }
    }
}
名称空间MyNamespace
{
公共类MultipleHostServiceFactory:ServiceHostFactory
{
受保护的重写ServiceHost CreateServiceHost(类型serviceType,Uri[]baseAddresses)
{
列表地址=新列表();
address.Add(基本地址[0]);
返回base.CreateServiceHost(serviceType,addresses.ToArray());
}
}
}
接下来,需要在.svc文件的标记中设置工厂:

<%@ ServiceHost Language="C#" 
                Debug="false" 
                Factory="MyNamespace.MultipleHostServiceFactory" 
                Service="MyNamespace.MyService" 
                CodeBehind="MyService.svc.cs" %>

很可能.svc扩展未在IIS下注册为由ASP.NET(WCF)处理

尝试以下两个步骤(如果需要,请用Framework64替换框架):

转到:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\
然后运行:

aspnet_regiis -i
转到: C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation

然后运行:

ServiceModelReg.exe -i

Internet信息服务(IIS)管理器
下,打开名为
Web服务扩展
的节点。确保
ASP.NET v2.0.5.0727
设置为允许。我花了几个小时寻找不同的设置,发现它被设置为禁止。只需单击“允许”按钮即可启用ASP.NET。

我也遇到了同样的问题。结果是,我运行的是64位版本的Windows2003Server,并将我的程序集配置为“任意CPU”。一旦我将程序集更改为x86并上传到服务器,一切都正常了

我不知道为什么在我读到的30条帖子中没有人提到它,但我的朋友向我推荐了它,它就像一个符咒


只是把它扔出去以防万一有人有同样的问题。

我有同样的问题,并通过允许ISAPI扩展解决了它。在Internet信息服务(IIS)管理器下,打开名为Web服务扩展的节点。确保将“所有未知ISAPI扩展”设置为“允许”。

我为此奋斗了数小时,直到我最终使用了这个示例,它第一次起作用:

我知道只有链接的答案并不好,其他人也使用了这个CP链接,因此,如果这篇文章出现问题,下面是一些基本步骤:

第一步

首先,发布VisualStudio2010。单击文件->新建->项目。创建新的“WCF服务应用程序”

步骤2

创建项目后,您可以在解决方案中看到默认情况下已经创建了WCF服务和接口文件(Service1.cs和IService.cs)。删除这两个文件,我们将创建自己的接口和WCF服务文件

步骤3

现在右键单击解决方案并创建一个新的WCF服务文件。我将服务文件命名为“RestServiceImpl.svc”

步骤4

正如我在文章开头所解释的,我们将编写一个API,它可以返回XML和JSON格式的数据,下面是它的接口。在IRestServiceImpl中,添加以下代码

在上面的代码中,您可以看到IRestService的两种不同方法,即XMLData和JSONData。XMLData返回XML格式的结果,而JSON格式的JSONData返回结果

[ServiceContract]
public interface IRestServiceImpl
{
    [OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "xml/{id}")]
    string XMLData(string id);

    [OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "json/{id}")]
    string JSONData(string id);
}
步骤5

打开文件RestServiceImpl.svc.cs并在那里编写以下代码:

public class RestServiceImpl : IRestServiceImpl
{
    public string XMLData(string id)
    {
        return "You requested product " + id;
    }

    public string JSONData(string id)
    {
        return "You requested product " + id;
    }
}
步骤6

Web.Config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
        </endpoint>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <!-- 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 name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

步骤7

在IIS中:


我所看到的没有主机头,只是在远程服务器或本地主机上使用IPIs this?如果是远程的,你有没有先在本地验证一切工作?这是一个救生圈!我只需要运行“aspnet_regiis”,它就解决了这个问题。如果你运行-我不会“破坏”以前所有的.net安装吗?我们的整个网站都在运行.NET1。。。我需要让wcf工作。我应该使用-I标志跑步吗?我不想改变任何现有的东西。谢谢你,你刚刚修复了我的部署!这是给我的。其他一切都安排好了。谢谢:)