Inheriting from a generic contract in WCF

后端 未结 3 1019
遥遥无期
遥遥无期 2021-01-12 12:13

More WCF woes... :)

All my workflows implement the same 3 methods. After a lot of copy and paste, I decided to make them inherit from the same interface:

<         


        
相关标签:
3条回答
  • 2021-01-12 12:38

    Why don't you specify a name for your contract in the ServiceContract attribute:

    [
    ServiceContract
       (
        Namespace = "http://schema.company.com/messages/", 
        Name="MyBasicContract"
        )
    ]
    

    If you don't explicitlly specify a name, it will default to the qualified name of your interface in "that weird syntax that .NET uses".

    0 讨论(0)
  • 2021-01-12 12:42

    "that weird syntax that .NET uses" is actually the type name at runtime for a generic type bound to specific types. Typename`n[[Type],...] where n denotes the number of type arguments contained in your generic type.

    How does your endpoint configuration then look like?

    0 讨论(0)
  • 2021-01-12 12:42

    You must use the standard way of defining generic types in configuration file if you want to use a service contract like IBasicContract

    It is written in the configuration file like this: IBasicContract`2[TRequest,TResponse]

    I also replied on my blog (www.lybecker.com/blog/) as you posted the question their too.

    :-) Anders Lybecker

    0 讨论(0)
提交回复
热议问题