我有一个 WCF 服务,可以在运行 IIS 7 的开发机器上运行,但我的同事正在运行 IIS 5.1 (XP)。当他导航到服务页面时,他可以在 Web 浏览器中查看服务,但如果他尝试调用操作或在 Web 浏览器中导航到该操作,则会收到 404 错误。
我让他运行 ServiceModelReg -i,但这并没有改变任何东西。我让他导航到 .svc?wsdl 页面,该方法在此处列出。但是当他尝试导航到该方法(它使用 WebGetAttribute)时,IIS 返回 404。有什么想法吗?
更新
只有当他从 IIS 运行站点时才会出现问题。如果他使用 Visual Studio Web Server (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>