mic*_*ael 0 generics wcf contract endpoint
码:
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
}
}
Run Code Online (Sandbox Code Playgroud)
简明代码:
public class XService :
IGenericService<MyType>
{
GenericResponse<MyType> DoFoo(GenericRequest<MyType> request)
{
//Do Stuff Here
}
}
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
我如何在合同名称中加入实际工作?
通常,您可以通过以下代码片段了解WCF期望您为ContractName添加的内容:
ContractDescription.GetContract(typeof(IGenericService<MyType>)).ConfigurationName
Run Code Online (Sandbox Code Playgroud)