Sunday, August 19, 2007

How to create WCF service proxy without publishing mex endpoint


Some time ago I needed to create WCF service proxy, while I don't wanted to expose and publish MEX endpoint for it (and then generate the proxy from its wsdl). Strangely, but I didn't found any clue on how to do it in the Google depths. Even MSDN articles (1 and 2) devoted to the SvcUtil doesn't mention it in a straightforward way. Here is how to do it:

1) Create WSDL and XSD definitions for your service. Use following command:
svcutil /serviceName:MyService.MyServiceClass MyServiceAssembly.exe /reference:MyServiceContracts.dll
(You'll need to reference additional assemblies related to the service, like I did with MyServiceContracts.dll)

2) Generate proxies and corresponding client WCF configuration in .config file:
svcutil *.wsdl *.xsd /language:C#

2 comments:

Alex Pinsker said...

See update.

Unknown said...

Can you please post an elaborate tutorial. I have been searching for it.