在 Windows Server 2008 中无法访问 WCF 服务

发布于 2024-11-07 06:27:43 字数 2568 浏览 0 评论 0原文

我最近构建了一个 WCF 服务,现在将其部署到 Windows Server 2008。现在,我们没有打开安全协议。但我们会的。无论哪种方式我都想让它工作。在该网站中,我启用了匿名身份验证以及表单身份验证。我这样做的原因是为了防止在 iPad、Android 和 Internet Explorer 上弹出身份验证窗口。所以现在他们只是进入登录屏幕。哦,我确实在 Windows 功能中激活了 WCF。如果您也了解如何准备好 https,我也想弄清楚这一点。谢谢!!

当我尝试将 *.svc PATH 粘贴到 URL 中时,出现此错误。

System.ServiceModel.ServiceActivationException: 服务 '/WCFServices/Accessioning/QuickDataEntryService.svc' 由于以下原因无法激活 编译时出现异常

这是迄今为止我的 web.config 配置。

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        <!--<baseAddressPrefixFilters>
            <add prefix="http://localhost/" />
        </baseAddressPrefixFilters>-->
    </serviceHostingEnvironment>
    <behaviors>
        <endpointBehaviors>
            <behavior name="AspNetAjaxBehavior">
                <enableWebScript />
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
            <!-- Watch this section when adding a new WCF Service!  New behaviors will be added; just delete them and use "ServiceBehavior" -->
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="ServiceBehavior" name="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
            <endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding"
                contract="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
        <!--<service name="A.LIMS.UI.Web.WCFServices.Accessioning.IQuickDataEntryService"
                 behaviorConfiguration="ServiceBehavior">
            <endpoint behaviorConfiguration="AspNetAjaxBehavior"
                      binding="webHttpBinding"
                      contract="A.LIMS.UI.Web.WCFServices.Accessioning.IQuickDataEntryService" />
        </service>-->
        <!-- Watch this section when adding a new WCF Service!  Duplicate the "QuickDataEntryService" above for an example, but change the fully qualified name -->
    </services>
</system.serviceModel>

I recently built a WCF Service, and now I'm deploying it to Windows Server 2008. Right now, we don't have secure protocol turned on. But we will. I'd like to get it working either way. In the site, I've had Anonymous authentication enabled as well as Forms authentication. The reason I did this was to prevent the authentication popup on the iPad, Android and Internet Explorer. So now they just get to the Login screen. Oh and I did activate WCF in Windows features. If you're also knowledgeable about making this https ready, I'd also like to figure that out. Thanks!!

I'm getting this error when I try pasting in the *.svc PATH into the URL.

System.ServiceModel.ServiceActivationException:
The service
'/WCFServices/Accessioning/QuickDataEntryService.svc'
cannot be activated due to an
exception during compilation

Here is my web.config configuration thus far.

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        <!--<baseAddressPrefixFilters>
            <add prefix="http://localhost/" />
        </baseAddressPrefixFilters>-->
    </serviceHostingEnvironment>
    <behaviors>
        <endpointBehaviors>
            <behavior name="AspNetAjaxBehavior">
                <enableWebScript />
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
            <!-- Watch this section when adding a new WCF Service!  New behaviors will be added; just delete them and use "ServiceBehavior" -->
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="ServiceBehavior" name="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
            <endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding"
                contract="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
        <!--<service name="A.LIMS.UI.Web.WCFServices.Accessioning.IQuickDataEntryService"
                 behaviorConfiguration="ServiceBehavior">
            <endpoint behaviorConfiguration="AspNetAjaxBehavior"
                      binding="webHttpBinding"
                      contract="A.LIMS.UI.Web.WCFServices.Accessioning.IQuickDataEntryService" />
        </service>-->
        <!-- Watch this section when adding a new WCF Service!  Duplicate the "QuickDataEntryService" above for an example, but change the fully qualified name -->
    </services>
</system.serviceModel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风蛊 2024-11-14 06:27:43

我不知道是什么导致了上述异常,但这是最终的判决。 WCF 和使用 SSL 证书(HTTPS 协议)需要很多东西。请原谅格式。我不喜欢 Stack Overflow 有时将代码放入一个块中,有时则不然。

HTTPS 上的 web.config 需要以下内容:

以下是一些需要“requireSSL”属性的位置:


<表单loginUrl =“Login.aspx”超时=“30”保护=“全部”requireSSL =“true”/> />

注意下面“httsGetEnabled”中的“s”:

<行为>
<端点行为>
<行为名称=“AspNetAjaxBehavior”>
<启用WebScript />


<服务行为>
<行为名称=“ServiceBehavior”>
>



绑定(在非 SSL web.config 中缺失):

<绑定>

<绑定名称=“webBinding”>
<安全模式=“传输”>



服务(注意“mexHttpsBinding”中的“s”):

    <services>
        <service behaviorConfiguration="ServiceBehavior" name="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
            <endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>

    </services>

最后但并非最不重要的。我没有使用 .NET 4.0,但我确实在另一台机器上尝试过 .NET。对于.NET 4.0,如果不将其配置为实际使用的 URL,我就无法使 WCF 服务正常工作。如果同一 IP 有两个域,WCF 仅使用 web.config 中 system.ServiceModel XML 块内此块中的域。我没有在 .NET 4.0 中测试 https,因此我假设 URL 上的协议为 https:


<基本地址前缀过滤器>
<添加前缀=“http://subdomain.domain.com/”/>

哦,我还必须在 Windows Server 2008 机器上打开 WCF。并且需要重新启动服务器!

I have no clue what caused the exception above, but here was the final verdict. There were a lot of things required for WCF and using an SSL certificate (HTTPS protocol). Pardon the formatting.. I don't like how Stack Overflow sometimes puts the code into a block and sometimes it doesn't.

The following were required for the web.config on HTTPS:

Here are some places that required the "requireSSL" attribute:

<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="30" protection="All" requireSSL="true" />
</authentication>
<httpCookies httpOnlyCookies="false" requireSSL="true" domain="" />

Notice the "s" in "httsGetEnabled" below:

<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>

Bindings (missing in non-SSL web.config):

<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>

Services (notice the "s" in "mexHttpsBinding"):

    <services>
        <service behaviorConfiguration="ServiceBehavior" name="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
            <endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>

    </services>

Last but not least. I'm not using .NET 4.0, but I did try .NET on a different machine. With .NET 4.0 I couldn't get the WCF services to work without having this configured to the actual URL being used. If there were two domains for the same IP, WCF only worked with the domain in this block inside the system.ServiceModel XML block in the web.config. I did not test https in the .NET 4.0, so I'm assuming the protocol on the URL would be https below:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://subdomain.domain.com/" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

Oh, I also had to turn on WCF on the Windows Server 2008 box. And it required a server reboot!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文