WCF服务操作 - 获取失败,404
问题描述:
我有一个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>
答
添加XP机器上IIS中的通配符映射。将*.*
映射到C:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ aspnet_isapi.dll,并取消选中“验证文件存在”复选框。
根据您的REST URL的格式,您可能需要放.*
代替*.*
(做你的URL看起来像目录或文件一样?)
答
尝试在服务URL的末尾添加/soap
。
谢谢,我的同事暂时不在,所以我无法真正验证修复,但我认为你是对的。我忘记了脚本地图。 – 2009-07-02 18:35:20