我有一個WCF服務在我的開發機器上運行IIS 7,但我的同事正在運行IIS 5.1(XP)。當他導航到服務頁面時,他可以在Web瀏覽器中查看服務,但是如果他嘗試調用操作或在他的Web瀏覽器中導航到該服務,他將得到404錯誤。WCF服務操作 - 獲取失敗,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>
謝謝,我的同事暫時不在,所以我無法真正驗證修復,但我認爲你是對的。我忘記了腳本地圖。 – 2009-07-02 18:35:20