Visual Studio 2013 C#WCF Web服务_vti_bin / ListData.svc / $ metadata

埃米利奥

上下文如下:

创建WCF服务:Framework .NET 4.0

  • 在IIS 7下部署它
  • 该Web服务包含
  • 对检索数据集的库的引用
  • WCF利用数组中的方法
  • 我需要禁用“匿名身份验证”并启用“ Windows身份验证”
  • 我将该服务作为Web服务使用(我不想使用svcutil生成的文件)
  • Web服务的端点是“ mywebpoint / mywcf_web_service.svc”

当我开发解决方案时Visual Studio 2010,一切正常,一切都按预期进行。

我使用Visual Studio 2013重建了解决方案,现在由于引用要查询凭据的Web服务而不再起作用:

  • “ mywebpoint / mywcf_web_service.svc / _vti_bin / ListData.svc”和
  • “ mywebpoint / mywcf_web_service.svc / _vti_bin / ListData.svc / $ metadata”

检查DNS和代理身份验证...没有错

这里是Web.Config:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Windows" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />

    <webServices>
      <protocols>
        <add name="HttpGet" />
        <add name="HttpPost" />
        <add name="HttpSoap12" />
        <add name="HttpSoap" />
      </protocols>
    </webServices>

    <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm" />
  </system.web>

  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="myBasicHttpBinding" bypassProxyOnLocal="true">
          <security mode="TransportCredentialOnly">
          <!--<security mode="Transport">-->
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <services>
      <service name="WCF_MyWebService.Service" behaviorConfiguration="WCF_MyWebService.ServiceBehaviour">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBasicHttpBinding" name="BasicHttpEndpoint" contract="WCF_MyWebService.IService" >
          <identity>
            <dns value="" />
          </identity>
        </endpoint>
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> ??? I didn't need this with Visula Studio 2010!!!
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="WCF_MyWebService.ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />

  </system.webServer>



</configuration>

这是我尝试在IIS服务器上打开URL时在网页上看到的错误:


Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.]
   System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateHttpSettings(String virtualPath, Boolean isMetadataListener, Boolean usingDefaultSpnList, AuthenticationSchemes& supportedSchemes, ExtendedProtectionPolicy& extendedProtectionPolicy, String& realm) +198236
   System.ServiceModel.Channels.HttpChannelListener.ApplyHostedContext(String virtualPath, Boolean isMetadataListener) +104
   System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener(BindingContext context) +156
   System.ServiceModel.Channels.Binding.BuildChannelListener(Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters) +166
   System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession) +393
   System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result) +583
   System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +2020
   System.ServiceModel.ServiceHostBase.InitializeRuntime() +82
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +64
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +255
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivationException: The service '/WCF_Excelnet_CoreSvc/WCF_Excelnet_Core.svc' cannot be activated due to an exception during compilation.  The exception message is: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +901424
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178638
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107

这真令人沮丧和令人失望...

如果我清理完Web.confing并重新存储了匿名身份验证,那么一切都很好。

使用Web服务肯定有些麻烦,但我的选择已经用光了...

埃米利奥

好吧,终于我解决了这个问题...但是您不会喜欢它。基本上,相同的解决方案仅在IIS 8.0下运行良好。这意味着您必须安装Win Server 2012等。。。此外,不要忘记在属性中设置“ Windows Authenticated” = Enabled。

这是我设法使其正常工作的唯一方法...对不起。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Visual Studio 2013服务参考

来自分类Dev

Visual Studio 2013服务参考

来自分类Dev

Visual Studio 2013 Web设置

来自分类Dev

SqlDataAdapter C#WCF服务

来自分类Dev

Visual Studio 2013 C ++-准则

来自分类Dev

Visual Studio 2013无法访问本地托管的WCF Web服务

来自分类Dev

Visual Studio 2013-未安装Visual Basic / Visual C#Web模板

来自分类Dev

Visual Studio 2013-未安装Visual Basic / Visual C#Web模板

来自分类Dev

使用Visual Studio 2013在C#中创建Asmx Web服务

来自分类Dev

Visual Studio 2013 Web Deploy fails

来自分类Dev

Visual Studio 2013使Web Essentials崩溃

来自分类Dev

Visual Studio 2013 Express解决Web问题

来自分类Dev

无法卸载Visual Studio Express 2013 for Web

来自分类Dev

Visual Studio 2013的Web部署工具

来自分类Dev

c#WCF服务返回集合

来自分类Dev

Visual Studio 2013 C ++标准库

来自分类Dev

Visual Studio 2013编译严格的C ++ 11

来自分类Dev

Visual Studio 2013中的C ++ 11 Chrono

来自分类Dev

在Visual Studio C ++ 2013中设置图形

来自分类Dev

Visual Studio 2013中的调试技术c ++

来自分类Dev

C ++中的数字溢出(Visual Studio 2013)

来自分类Dev

长浮游C ++ Visual Studio 2013

来自分类Dev

VIsual Studio 2013中C上的GUI

来自分类Dev

在Visual Studio 2013上启用c ++ 11

来自分类Dev

C ++ Visual Studio 2013编译错误?

来自分类Dev

即时打印Visual Studio 2013 C#

来自分类Dev

WCF服务库模板在Visual Studio 2013 Express上不可用?

来自分类Dev

在Visual Studio Pro 2013中添加WCF服务/项目模板吗?

来自分类Dev

Visual Studio 2013新建项目基于Visual C#服务的数据库项丢失