WCF Proxy Creation and Known Issues with Solution
When developing wcf service and creating proxy of that wcf service many users will may face some issues like Getting a common error while creating proxy or adding service reference, add service reference not working, user not able to create metadata (wsdl) so in this article we will discuss about how to create proxy and how to resolve known issues.
Create proxy by using svcutil
Go to Visual Studio Command Prompt and run as administrator if you are working on windows 7 machines and make sure you will have svcutil.exe in your .net framework.
Run your service or view your service in browser and Go to C:\\ prompt and type Svcutil.exe "URL of Your Wcf Service" e.g.
C:\svcutil.exe http://localhost:10650/Service1.svc?wsdl
Note : Make sure you should have sufficient rights to create file on the specified path because svcutil will create your proxy class on the given path.
Known Issue:
1 Not having svcutil.exe in your framework.
2 Access to path is denied.
3 Error: Cannot obtain Metadata from service has been exceeded quota.
4 SvcUtil having timeout limit of 5 minute to get the metadata.
Framework specific tool will work with their own classes' mean we cannot generate proxy from the SDK 3.5 using 4.0 SvcUtil tool and i.e. technically called multi targeting.
Solution to Known Issues:
1. Install Svcutil.exe from the msdn or Microsoft framework SDK
2 Give Admin or Read/Write Access to User from which you login.
3 Set readerQuotas maxDepth="2147483647" and other settings as well.
Note : For more known advance issues you can refer this link given below
http://msdn.microsoft.com/en-us/library/ee517280.aspxAdding Service Reference / Update Service Reference
Run your service or view your service in browser go to client project where you want to add service reference then right click on project and click on Add Service Reference Menu Item popup will open then if the service is running within the same solution then discover it and click on ok button to add service reference.
While Adding Reference we can do following things:
1. We can generate asynchronous operation / methods.
2. We can generate message contract if required
3. We can set Data type we need it from service default is Array and Dictionary as Collection
Known Issue With Solution:
1. Abstract class referenced as known types or used as a data contract will not able to add service reference or can't create proxy for the same.
2. Partial class never to be derived from the FaultBase class.
3. Type sharing between XmlSerializer and DataContract will not work here we have to force to tool to skip that we can use svcutil Option : /serializer:DataContractSerializer.
4. Point to remember we have to specify endpoint configuration name properly.
Note: Most of the time seen the error in data type or contract only some time we forget to put some attributes over the methods or data member and some time we will have issue with fault contract. I will keep on adding the known issue with solution in this article.
Very informative, Thanks for info.