WCF服务操作 - GET因404失败

时间:2021-07-17 20:28:15

I have a WCF service which works on my dev machine running IIS 7, but my coworker is running IIS 5.1 (XP). He can view the service in a web browser when he navigates to the service page, but if he tries to call an operation or navigate to it in his web browser he gets a 404 error.

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

I had him run ServiceModelReg -i, but that didn't change anything. I had him navigate to the .svc?wsdl page and the method is listed there. But when he tries to navigate to the method (it uses the WebGetAttribute) IIS returns 404. Any ideas?

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

Update

The problem only happens if he is running the site from IIS. If he loads the project using the Visual Studio Web Server (cassini) it works fine.

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

I don't think the issue is with the service itself, but just in case here it is:

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

    [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();
}

Here's the web.config:

这是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 个解决方案

#1


Add a wildcard mapping in IIS on the XP machine. Map *.* to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll and uncheck the "Verify File Exists" checkbox.

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

Depending on the format of your REST urls, you may need to put .* instead of *.* (do your URLs look like directories or like files?)

根据REST URL的格式,您可能需要输入。*而不是*。*(您的URL看起来像目录还是类似文件?)

#2


Try adding /soap at the end of the service URL.

尝试在服务URL的末尾添加/ soap。

#1


Add a wildcard mapping in IIS on the XP machine. Map *.* to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll and uncheck the "Verify File Exists" checkbox.

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

Depending on the format of your REST urls, you may need to put .* instead of *.* (do your URLs look like directories or like files?)

根据REST URL的格式,您可能需要输入。*而不是*。*(您的URL看起来像目录还是类似文件?)

#2


Try adding /soap at the end of the service URL.

尝试在服务URL的末尾添加/ soap。