开发者

WCF Endpoint Contract Name -- How to assign it if it is generic?

开发者 https://www.devze.com 2023-03-15 11:00 出处:网络
IGenericService resides in the Assembly Named: \"ABC.Server.Common\" (ABC.Server.Common.dll) MyType resides in the Assembly Named: \"ABC.Server.Modules.X\" (ABC.Server.Modules.X.dll)
  • IGenericService resides in the Assembly Named: "ABC.Server.Common" (ABC.Server.Common.dll)
  • MyType resides in the Assembly Named: "ABC.Server.Modules.X" (ABC.Server.Modules.X.dll)

CODE:

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
    }
}

Condensed Code:

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

Web.config:

I don't use SVC files, instead I have that information taken care of in the 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="Standa开发者_开发技巧rdBehavior">
  <endpoint bindingConfiguration="StandardBinding"
            binding="basicHttpBinding"
            contract="?" />
</service>

What do I put in the contract name to get it to actually work?


In general you can learn what WCF is expecting you to put for the ContractName with the following code snippet:

ContractDescription.GetContract(typeof(IGenericService<MyType>)).ConfigurationName
0

精彩评论

暂无评论...
验证码 换一张
取 消