我想在一個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風格的服務工作 –