WCF服务在本地工作,但在远程服务器上返回404
问题描述:
我创建了最简单的WCF服务来尝试和学习非常基础的知识。当我在本地主机上运行它时,它工作正常。但是,当我把它部署到远程服务器,它返回一个404WCF服务在本地工作,但在远程服务器上返回404
配置:
<system.serviceModel>
<services>
<service name="MarathonInfo.MarathonInfoService">
<endpoint address="http://localhost:10298/MarathonInfoService.svc"
binding="webHttpBinding"
contract="MarathonInfo.IMarathonInfo"
behaviorConfiguration="Web"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
服务文件:
namespace MarathonInfo
{
public class MarathonInfoService : IMarathonInfo
{
public String GetData()
{
return "Hello World";
}
}
}
和接口:
namespace MarathonInfo
{
[ServiceContract]
public interface IMarathonInfo
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
String GetData();
}
}
基于我通过Google找到的信息,我非常肯定我需要添加一个新的端点,但是我一直未能取得任何成功。我的远程URL如下所示:
http://www.mydomain.com/service/MarathonInfoService.svc
任何想法如何解决?
谢谢!
答
问题是与以下行:
address="http://localhost:10298/MarathonInfoService.svc"
与适当的URL替换它,当你在服务器上部署它。
唉!我应对了上一个问题的配置,而不是来自实际的配置文件下面是我真正得到的: ' ' –
user1418704
确保您用来引用服务的URL是正确的。把一个简单的HTML文件放在那里,并尝试访问它,以确保它没有一些权限问题。 – decyclone
好吧,我将端点更改为以下,仍然从远程服务器得到404错误: –
user1418704