WCFはどのクラスを使用するかをどのように知るのでしょうか?
あなたがそれを言うので、様々な設定ファイルで。
私は心からWCFを手動の方法でお勧めします…モチベーションの正しい方法とあなたがやろうとしていることの完全なウォークスルー-私がここに持っているのはそのような実装の適切なポイントです。
3つのアセンブリがあります:、、(Service
インターフェースのみ)。および両方の参照。インターフェイスを実装するクラスが含まれています。プロキシクラスがあります:Client
ServiceContracts
Service
Client
ServiceContracts
Service
Client
using System.ServiceModel;
using ServiceContracts;
public class ExampleServiceProxy : ClientBase<IExampleService>, IExampleService
{
public string ExampleMethod()
{
return Channel.ExampleMethod();
}
}
クライアントのファイルには、サービスのファイルconfig
を指すエントリが含まれています。svc
サービスのsvc
ファイルは次のようになります。
<%@ ServiceHost Language="C#" Debug="true" Service="Service.ExampleService"
CodeBehind="ExampleService.svc.cs" %>
そして、サービス.svc.cs
ファイルは次のようになります。
using ServiceContracts;
public class ExampleService : IExampleService
{
public string ExampleMethod()
{
return string.Empty;
}
}
それでおしまい!