過去4時間の間、私はこの質問に関して見つけた投稿を見てきました。そのため、今では少し盲目になるかもしれません;-)
jQueryを使用して単純なWCFサービスを呼び出そうとしています。私はしばらくの間WebMethodsを使用していて、いくつかを移行しようとしています。私はあなたが想像できる最も単純なウェブサービスでテストしようとしています:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ForumOperationService : IForumOperationService
{
public string Horse(string prefixText, int count)
{
return "hestWCF";
}
}
私のjQuery呼び出し:
$(document).ready(function () {
var hest;
$.ajax({
type: "POST",
datatype: "application/json",
url: "Services/ForumOperationService.svc/Horse",
data: { prefixText: 'a', count: 10 },
success: function (data) {
hest = data;
}
});
});
私のweb.configは次のようなものです:
<system.webServer>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="ForumOperationService">
<endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="IForumOperationService" />
</service>
</services>
.... (more stuff)
Firebugで、次のエラーが発生します。
NetworkError:500内部サーバーエラー-
http://localhost:21599/Client/Services/ForumOperationService.svc/Horse
何か案は?
更新:
WCFテストクライアントを実行したところ、次のエラーが発生しました。
タイプForumOperationServiceのサービスクラスは、ServiceContractを定義し、タイプIForumOperationServiceからServiceContractを継承します。コントラクトの継承は、インターフェイスタイプ間でのみ使用できます。ÿクラスがServiceContractAttributeでマークされている場合、それはServiceContractAttributeを持つ階層内の唯一のタイプである必要があります。ÿタイプIForumOperationServiceのServiceContractAttributeを、タイプIForumOperationServiceが実装する別のインターフェースに移動することを検討してください。
明日フォローアップします。