我想在一个web.config中使用多个服务。我遇到的问题是,当我去https://localhost/APGame.WebHost/PlayService.svc/checktraining?g=3时,我得到资源找不到错误(404)。我曾尝试使用一项服务和多项服务合同来执行此操作,但这也没有奏效。在一个配置中配置多个WCF绑定或服务
我可以访问https://localhost/APGame.WebHost/PlayService.svc,以便服务正在运行。我只是不确定我做错了什么。
的Web.config WCF
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="json">
<webHttp defaultOutgoingResponseFormat="Json" helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="APGame.Services.GameManager">
<endpoint address="" binding="wsHttpBinding" contract="APGame.Contracts.IGameService" />
</service>
<service name="APGame.Services.PlayManager">
<endpoint address="" behaviorConfiguration="json" binding="webHttpBinding" contract="APGame.Contracts.IPlayService" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding transactionFlow="true" sendTimeout="00:20:00">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add service="APGame.Services.GameManager" relativeAddress="GameService.svc" />
<add service="APGame.Services.PlayManager" relativeAddress="PlayService.svc" />
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
服务合同
[ServiceContract]
public interface IPlayService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/checktraining?g={groupGameId}")]
bool? CheckTraining(int groupGameId);
}
您是否可以用了SoapUI,得到的结果里面? –
您没有“APGame.Contracts.IGameService”合同。 – granadaCoder
@granadaCoder我确实有IGameService的合同,并且工作得很好。我试图创建一个新的服务或新的服务合同,作为ajax w/AngularJS的REST风格的服务工作 –