WCF服务操作 - GET因404失败

时间:2009-07-02 16:53:39

标签: wcf http-status-code-404

我有一个WCF服务,可以在运行IIS 7的开发机器上运行,但是我的同事正在运行IIS 5.1(XP)。他可以在导航到服务页面时在Web浏览器中查看该服务,但如果他尝试调用操作或在其Web浏览器中导航到该操作,则会出现404错误。

我让他运行ServiceModelReg -i,但这并没有改变任何东西。我让他导航到.svc?wsdl页面并在那里列出方法。但当他尝试导航到该方法(它使用WebGetAttribute)时,IIS返回404.任何想法?

更新

只有从IIS运行该站点时才会出现此问题。如果他使用Visual Studio Web服务器(cassini)加载项目,它可以正常工作。

我不认为这个问题与服务本身有关,但以下是:

    [ServiceContract]
public interface IPFDClientAuthentication {
    [OperationContract]
    [WebGet(UriTemplate="/Logon?username={username}&password={password}",
        BodyStyle=WebMessageBodyStyle.WrappedResponse,
        ResponseFormat=WebMessageFormat.Json)]
    [JSONPBehavior(callback="callback")]
    bool Logon(string username, string password);

    [OperationContract]
    [WebGet(UriTemplate = "/Logout",
        BodyStyle = WebMessageBodyStyle.WrappedResponse,
        ResponseFormat = WebMessageFormat.Json)]
    [JSONPBehavior(callback = "callback")]
    bool Logout();

    [OperationContract]
    [WebGet(UriTemplate="/GetIdentityToken",
        BodyStyle=WebMessageBodyStyle.WrappedRequest,
        ResponseFormat=WebMessageFormat.Json)]
    [JSONPBehavior(callback= "callback")]
    string GetIdentityToken();
}

这是web.config:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
    <service behaviorConfiguration="PFD.AuthenticationService.PFDClientAuthenticationBehavior"
                     name="PFD.AuthenticationService.PFDClientAuthentication">
        <endpoint address="" behaviorConfiguration="PFD.AuthenticationService.PFDClientEndpointBehavior"
                         binding="customBinding" bindingConfiguration="clientBinding"
                         name="clientEndpoint" contract="PFD.AuthenticationService.IPFDClientAuthentication">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
</services>
<bindings>
    <customBinding>
        <binding name="clientBinding">
            <jsonpMessageEncoding/>
            <httpTransport manualAddressing="true"/>
        </binding>
    </customBinding>
</bindings>
<behaviors>
    <endpointBehaviors>
        <behavior name="PFD.AuthenticationService.PFDClientEndpointBehavior">
            <webHttp />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="PFD.AuthenticationService.PFDClientAuthenticationBehavior">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
    </serviceBehaviors>
</behaviors>
<extensions>
    <bindingElementExtensions>
        <add name="jsonpMessageEncoding" type="Microsoft.Ajax.Samples.JsonpBindingExtension, 
                 PFD.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </bindingElementExtensions>
</extensions>

2 个答案:

答案 0 :(得分:1)

在XP计算机上的IIS中添加通配符映射。将*.*映射到C:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ aspnet_isapi.dll并取消选中“验证文件存在”复选框。

根据您的REST网址的格式,您可能需要放置.*而不是*.*(您的网址看起来像目录还是文件?)

答案 1 :(得分:0)

尝试在服务网址末尾添加/soap