Share via


How to write Serviced components for WCF?

If you want to expose serviced component as WCF service, you have to define custom interface for all your serviced component public methods(you can have multiple custom interfaces also) and then serviced component has to implement that interface.

If you don't have custom interface in serviced componnet, all methods will fall into default interface, ComSvcConfig.exe not going to expose default interface as WCF service.

I spoke to one of developers to know why we are not exposing default interface as WCF service, Here is reason

The main reason is that a class interface is a CLR metaphor and mapping it to a contract is non trivial and people expect class like behavior with it which we are not guaranteeing the whole idea is that if you use interfaces then you are much closer programming model wise to Indigo. And this is exactly what we are promoting

If you already wrote Service component, you can use c# refactoring support to extract interface for that class and then implement that interface.

REFERENCE:

https://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/WCF_tools/html/7717c6c2-85fc-418b-a8ed-bad8e61cec5c.asp

on my machine,I am trying to generate config file for StudentManagement COM+ application,I followed these instructions to generate config file

EXAMPLE:

STEP1:

install your svc component in GAC

C:\WINDOWS\WinFX\v3.0\Windows Communication Foundation>gacutil /i C:\customers\WCF\StudentManagement\StudentManagement.dll

STEP2:

by using regsvcs,install it in COM+

C:\WINDOWS\WinFX\v3.0\Windows Communication Foundation>regsvcs C:\customers\WCF\StudentManagement\StudentManagement.dll

STEP3:

Run comsvcconfig file to generate config file

//When you are using contract option,you are going to use this format

COMPONENT NAME,INTERFACE NAME

C:\WINDOWS\WinFX\v3.0\Windows Communication Foundation>comsvcconfig /i /applicat

ion:StudentManagement /hosting:was /webDirectory:TESTAPP /mex /contract:StudentM

anagement.Students,IStudents /v