Saturday, August 15, 2015

WCF Services - How to consume a Service without access to it

When working on a project that contains decentralized approach, different modules are deployed on different servers by different development teams and all that needs to be integrated with each other, there can be issues regarding accessing a web service that hasn't been published for access yet or is deployed on another domain with access restriction.

To access a contract for a service that is out of reach, Visual Studio provides a tool svcutil.exe that can generate a proxy for the service. This tool needs to be executed on the machine the service is deployed to in order for it to generate the required proxy.

Executing the svcutil.exe on command line with the following command will generate the proxy
C:\path> svcutil /t:code /language=cs http://<service address> /out:MyServiceProxy.cs /config:ServiceProxy.config
Now the generated .cs file can be added to the client application project to obtain the classes and method contracts. The endpoint configuration is generated in the .config file that can pe copied to the web.config file of the client application project.

If svcutil.exe is not available in the server machine, it is available for download in the internet as WCF Test Client package.

No comments :

Post a Comment

enter comment