Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF服务404错误_Wcf_Http_Service_Handler - Fatal编程技术网

WCF服务404错误

WCF服务404错误,wcf,http,service,handler,Wcf,Http,Service,Handler,我正在尝试设置WCF服务,但遇到了一些问题。当我输入时,服务工作并加载wsdl页面 www.mydomain.com/Service1.svc 但是当我使用 www.mydomain.com/Service1.svc/ 或者尝试使用我得到的任何get方法 The resource cannot be found. Description: HTTP 404. 我的web.config文件如下 <?xml version="1.0"?> <configuration>

我正在尝试设置WCF服务,但遇到了一些问题。当我输入时,服务工作并加载wsdl页面

www.mydomain.com/Service1.svc
但是当我使用

www.mydomain.com/Service1.svc/
或者尝试使用我得到的任何get方法

The resource cannot be found.

Description: HTTP 404.
我的web.config文件如下

<?xml version="1.0"?>
<configuration>

  <system.webServer>
    <handlers>
      <remove name="PageHandlerFactory-ISAPI-4.0"/>
      <add name="PageHandlerFactory-ISAPI-4.0" path="*" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <remove name="ASP.NET-ISAPI-4.0-Wildcard"/>
      <add name="ASP.NET-ISAPI-4.0-Wildcard"
         path="*" verb="GET,HEAD,POST,DEBUG"
         modules="IsapiModule"
         scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
         preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <remove name="svc-Integrated-4.0" />
      <add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0">
    </compilation>
    <httpHandlers>
      <remove verb="*" path="*.svc"/>
      <add path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
    </httpHandlers>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="RestService.Service1" behaviorConfiguration="ServiceBehaviour" >
        <endpoint address="" binding="webHttpBinding" contract="RestService.IService1" behaviorConfiguration="web">

        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://mydomain.com/Service1"/>
          </baseAddresses>
        </host>
      </service>

    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour" >
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>



    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
IService.cs的内容如下:

namespace RestService
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebInvoke(Method = "GET",
            ResponseFormat = WebMessageFormat.Json,
            //BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "login/{username}/{password}")]
        bool LoginUser(string username, string password);
    }
 }

如果有帮助的话,服务器上的管道模式是“集成”的。我不确定我的托管提供商(pipeten)使用的IIS版本是什么,但我认为它是7.5。我感觉这与URL验证有关,但我的托管上没有改变这一点的选项。

好的,原来这是我犯的一个简单错误,我错过了这个选项。添加处理程序时。它应该是path=“”,而不是path=“”



显示您正在创建的一些服务方法和请求url。您是否在IIS上托管?还要指定您的IIS版本和环境我添加了更多信息来显示我创建的方法!这并没有回答您的问题,但是您为什么要使用此自定义身份验证而不是标准的基本身份验证?这只是一个临时测试,我正在尝试它,稍后可能会更改为标准!
namespace RestService
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebInvoke(Method = "GET",
            ResponseFormat = WebMessageFormat.Json,
            //BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "login/{username}/{password}")]
        bool LoginUser(string username, string password);
    }
 }
<add name="ASP.NET-ISAPI-4.0-Wildcard"
         path=".*" verb="GET,HEAD,POST,DEBUG"
         modules="IsapiModule"
         scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
         preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />