2009-07-22 25 views
5

Tôi sau khi thiết lập một dịch vụ WCF trên hộp dev của tôi nhưng tôi nhận được một lỗi khi truy cập nó. Tôi đã đặt service up as per this guide. Nó được viết bằng VS2008/C#/.NET 3.5 và hộp dev của tôi là Vista SP2 với IIS 7. Tại thời điểm này dịch vụ không có gì hơn cấu trúc mặc định kể từ khi tôi theo nghĩa đen sau khi thử nghiệm kết nối với nó.Sự cố với Dịch vụ WCF - Giao thức 'http' không được hỗ trợ. Làm thế nào để giải quyết?

Tôi đã kiểm tra những gì cần phải được cài đặt và tôi khá chắc chắn tôi đã có tất cả mọi thứ được kích hoạt, ảnh chụp màn hình dưới đây cho thấy tùy chọn hiện tại: thông báo lỗi

Windows IIS Options

đầy đủ về việc tiếp cận http://localhost:8000/Service.svc như sau:

Server Error in '/' Application. 
-------------------------------------------------------------------------------- 

The protocol 'http' is not supported. 
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.InvalidOperationException: The protocol 'http' is not supported. 

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: 


[InvalidOperationException: The protocol 'http' is not supported.] 
    System.ServiceModel.AsyncResult.End(IAsyncResult result) +11536522 
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194 
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176 
    System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278 
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 


-------------------------------------------------------------------------------- 
Version Information: Microsoft .NET Framework Version:2.0.50727.4016; ASP.NET Version:2.0.50727.4016 

Bất kỳ đề xuất nào về cách gỡ lỗi/sửa lỗi sẽ được nhận biết ơn. Googling lỗi cho rất ít giúp đỡ. Tôi có lẽ đã bỏ lỡ một cái gì đó thực sự rõ ràng!

Sửa - web.config theo yêu cầu (xin lỗi cho chiều dài của nó):

<?xml version="1.0"?> 
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use 
    the Website->Asp.Net Configuration option in Visual Studio. 
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
--> 
<configuration> 
    <configSections> 
     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
       <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
       <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
        <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/> 
        <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
        <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
       </sectionGroup> 
      </sectionGroup> 
     </sectionGroup> 
    </configSections> 
    <appSettings/> 
    <connectionStrings/> 
    <system.web> 
     <!-- 
      Set compilation debug="true" to insert debugging 
      symbols into the compiled page. Because this 
      affects performance, set this value to true only 
      during development. 
     --> 
     <compilation debug="true"> 
      <assemblies> 
       <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
       <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
       <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
       <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
      </assemblies> 
     </compilation> 
     <!-- 
      The <authentication> section enables configuration 
      of the security authentication mode used by 
      ASP.NET to identify an incoming user. 
     --> 
     <authentication mode="Windows"/> 
     <!-- 
      The <customErrors> section enables configuration 
      of what to do if/when an unhandled error occurs 
      during the execution of a request. Specifically, 
      it enables developers to configure html error pages 
      to be displayed in place of a error stack trace. 

     <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> 
      <error statusCode="403" redirect="NoAccess.htm" /> 
      <error statusCode="404" redirect="FileNotFound.htm" /> 
     </customErrors> 
     --> 
     <pages> 
      <controls> 
       <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      </controls> 
     </pages> 
     <httpHandlers> 
      <remove verb="*" path="*.asmx"/> 
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/> 
     </httpHandlers> 
     <httpModules> 
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </httpModules> 
    </system.web> 
    <system.codedom> 
     <compilers> 
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
       <providerOption name="CompilerVersion" value="v3.5"/> 
       <providerOption name="WarnAsError" value="false"/> 
      </compiler> 
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
       <providerOption name="CompilerVersion" value="v3.5"/> 
       <providerOption name="OptionInfer" value="true"/> 
       <providerOption name="WarnAsError" value="false"/> 
      </compiler> 
     </compilers> 
    </system.codedom> 
    <system.web.extensions> 
     <scripting> 
      <webServices> 
       <!-- 
       Uncomment this section to enable the authentication service. Include 
       requireSSL="true" if appropriate. 

      <authenticationService enabled="true" requireSSL = "true|false"/> 
      --> 
       <!-- 
       Uncomment these lines to enable the profile service, and to choose the 
       profile properties that can be retrieved and modified in ASP.NET AJAX 
       applications. 

      <profileService enabled="true" 
          readAccessProperties="propertyname1,propertyname2" 
          writeAccessProperties="propertyname1,propertyname2" /> 
      --> 
       <!-- 
       Uncomment this section to enable the role service. 

      <roleService enabled="true"/> 
      --> 
      </webServices> 
      <!-- 
     <scriptResourceHandler enableCompression="true" enableCaching="true" /> 
     --> 
     </scripting> 
    </system.web.extensions> 
    <!-- 
     The system.webServer section is required for running ASP.NET AJAX under Internet 
     Information Services 7.0. It is not necessary for previous version of IIS. 
    --> 
    <system.webServer> 
     <validation validateIntegratedModeConfiguration="false"/> 
     <modules> 
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </modules> 
     <handlers> 
      <remove name="WebServiceHandlerFactory-Integrated"/> 
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </handlers> 
    </system.webServer> 
    <system.serviceModel> 
     <services> 
      <service name="Service" behaviorConfiguration="ServiceBehavior"> 
       <!-- Service Endpoints --> 
       <endpoint address="" binding="wsHttpBinding" contract="IService"> 
        <!-- 
       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. 
      --> 
        <identity> 
         <dns value="localhost"/> 
        </identity> 
       </endpoint> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8000/" /> 
      </baseAddresses> 
     </host> 
     </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="ServiceBehavior"> 
        <!-- 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> 
     </behaviors> 
    </system.serviceModel> 
</configuration> 

Chỉnh sửa 2 - Tôi đã gỡ bỏ đoạn về việc tạo ra một khách hàng Delphi Win32 từ Delphi 2007 không hỗ trợ SOAP 1.2, đó là những gì WCF Service sử dụng. Delphi 2007 chỉ hỗ trợ SOAP 1.0 ... Vì vậy, khách hàng bây giờ sẽ là một ứng dụng C# WinForms.

+0

Bạn đã cài đặt máy chủ dịch vụ làm cổng 8000? – Lazarus

+0

Có (theo hướng dẫn tôi đã liên kết). Tôi cũng đã thử cổng 80. Không vui. – Pauk

+0

Vui lòng đăng web.config, tôi nghi ngờ đó là sự cố cấu hình. – Lazarus

Trả lời

4

trả lời đối với tôi là như sau (được cung cấp bởi Lazarus trong các ý kiến, nhưng đã không trở lại để viết như một câu trả lời):

  1. Fired up Internet Information Services (IIS) Manager.
  2. Mở thư mục Siteschọn trang web được đề cập.
  3. phải nhấp nó, sau đó chọn Quản lý trang web và sau đó Advanced Settings ...
  4. Trên kết quả popup, tôi bước vào http trong Enabled Protocols hàng.
  5. Đóng cửa sổ bật lên và khởi động lại Trang web và đó là trang web. Đã sửa!
1

tôi thấy rằng nó gần như luôn luôn là một vấn đề với cách endpoint, bindings, và/hoặc behavior được cấu hình.

Đối với hầu hết các phần, nếu trang web của bạn trong IIS không có ràng buộc HTTP, thì hãy đảm bảo đặt httpGetEnabled = 'false' một cách rõ ràng trong cấu hình configuration/system.serviceModel/behaviors/serviceBehaviors/behavior/serviceMetadata tương ứng với dịch vụ WCF của bạn. Đường dẫn trên ofcourse là tham chiếu đến tệp web hoặc app.config của bạn.

Ngoài ra, nếu bạn có điểm cuối có 'http: //' trong địa chỉ, hãy xóa nó. WCF chú ý đến những điều này và sẽ ném cùng một thông báo lỗi mơ hồ. Có toàn bộ mê cung các cấu hình sai sản xuất cùng một thông báo lỗi. (Tôi ghét điều đó về WCF.) Tôi cụ thể hơn là: "Hey dumm as #! Bạn có một HTTP ở một trong những địa chỉ điểm cuối của bạn nhưng IIS không có ràng buộc HTTP!" P Atleast theo cách này tôi sẽ không đuổi đuôi tôi.

Tương tự như vậy, tôi không bao giờ sử dụng các điểm cuối mex vì chúng gặp nhiều rắc rối hơn thì chúng đáng giá. Thay vào đó, hãy sử dụng thuộc tính httpsHelpPageUrlhttpsHelpPageEnabled trong phần tử cấu hình configuration/system.serviceModel/behaviors/serviceBehaviors/behavior/serviceDebug (giả sử bạn đang sử dụng HTTPS).

0

Trả lời cho tôi là tắt và sau đó bật lại Siêu dữ liệu qua HTTP.

  1. Đã kích hoạt Trình quản lý dịch vụ thông tin Internet (IIS).
  2. Mở thư mục Siteschọn trang web được đề cập.
  3. phải nhấp nó, sau đó chọn Manage WCF và WF Dịch vụ và sau đó Configure ...
  4. Trên chung tab, tôi bỏ chọn Enable siêu dữ liệu qua giao thức HTTP (vâng, nó đã được kiểm tra đã).
  5. Nhấp vào Áp dụng (và xác nhận cảnh báo ứng dụng tái chế).
  6. Đã kiểm tra Bật siêu dữ liệu qua HTTP.
  7. Nhấp vào Áp dụng (và xác nhận cảnh báo ứng dụng tái chế), và đó là nó. Đã sửa!

... Hoặc có thể quá trình tái chế AppPool sẽ là đủ.

Các vấn đề liên quan