いくつかの特定の要件のために、私は複数のサービスバージョンに単一のsvcを使用する必要があります。異なる名前空間を使用して、バージョンごとにインターフェイスコントラクトを分離しました。すべてのサービスバージョンを実装するクラス(部分的)は1つだけです。
私のコードは以下の通りです:
namespace Application.V1
{
[ServiceContract(Namespace = "http://google.com/ApplicationService/v1.0", Name = "IMathService")]
public interface IMathService
}
namespace Application.V2
{
[ServiceContract(Namespace = "http://google.com/ApplicationService/v2.0", Name = "IMathService")]
public interface IMathService
}
Application / MathServiceV1.csファイル:
public partial class MathService : V1.IMathService { }
Application / MathServiceV2.csファイル:
public partial class MathService : V2.IMathService { }
Application / MathService.csファイル:
public partial class MathService {}
サービスweb.configに以下を追加しました。
<service behaviorConfiguration="ServiceBehavior" name="Application.MathService">
<endpoint address="V1" binding="wsHttpBinding" contract="Application.V1.IMathService" />
<endpoint address="V2" binding="wsHttpBinding" contract="Application.V2.IMathService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
MathService.svc
次のファイルがあります。
<%@ ServiceHost Service="Application.MathService, Application"
Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf"%>
アドレスを使用してプロキシを生成するとhttp://localhost:8000/MathService.svc
、クライアントエンドポイントは次のように生成されます。
<client>
<endpoint address="http://localhost:8000/MathService.svc/V1"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMathService"
contract="MathService.IMathService" name="WSHttpBinding_IMathService">
</endpoint>
<endpoint address="http://localhost:8000/MathService.svc/V2"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMathService1"
contract="MathService.IMathService1" name="WSHttpBinding_IMathService1">
</endpoint>
</client>
私の懸念は、クライアントエンドポイントアドレスがで生成されることですMathService.svc/V1
が、見たいV1/MathService.svc
です。
アドレスを指定してサービスを参照すると、エラーhttp://localhost:8000/MathService.svc/V1
が発生しHTTP 400 Bad Request
ます。
助言がありますか?