0
  • IGenericService は、"ABC.Server.Common" (ABC.Server.Common.dll) という名前のアセンブリに存在します。
  • MyType は、"ABC.Server.Modules.X" (ABC.Server.Modules.X.dll) という名前のアセンブリに存在します。

コード:

public class ABC.Server.Modules.XService :
    ABC.Server.Common.IGenericService<ABC.Server.Module.X.MyType>
{
    ABC.Server.Common.GenericResponse<ABC.Server.Module.X.MyType> DoFoo(ABC.Server.Common.GenericRequest<ABC.Server.Module.X.MyType> request)
    {
        //Do Stuff Here
    }
}

要約コード:

public class XService :
    IGenericService<MyType>
{
    GenericResponse<MyType> DoFoo(GenericRequest<MyType> request)
    {
        //Do Stuff Here
    }
}

Web.config:
私は SVC ファイルを使用しません。代わりに、その情報は Web.config で処理されます。

<add factory="System.ServiceModel.Activation.ServiceHostFactory"
     relativeAddress="Services/X.svc"
     service="ABC.Server.Modules.X.XService"/>

<service name="ABC.Server.Modules.X.XService"
         behaviorConfiguration="StandardBehavior">
  <endpoint bindingConfiguration="StandardBinding"
            binding="basicHttpBinding"
            contract="?" />
</service>

実際に機能させるには、コントラクト名に何を入力すればよいですか?

4

1 に答える 1

5

一般に、次のコードスニペットを使用して、WCFがContractNameに何を期待しているかを知ることができます。

ContractDescription.GetContract(typeof(IGenericService<MyType>)).ConfigurationName
于 2011-06-23T17:28:05.750 に答える