Skip to main content

Posts

Showing posts from May, 2010

Solution Array for List in WCF

Here is another common problem encounters with WCF Service in initial days. Suppose there is a method which returns a List of Objects the proxy will be generated as method which returns an array of objects. Reason: This problem is due to the default interpretation of collections. While generating proxy for the service all the collections are by default interpreted as arrays. That is why all the lists will be converted to arrays. Solution: If you are generating proxy by adding service reference from visual studio directly, there will be a 'advanced' button. Click that button and select the System.Generic.List as your Collection. This will resolve the problem. If you are generating proxy with svcutil here is the command to do the job. svcutil.exe http://ServerName/ServiceName/Servic.svc?wsdl /collectionType:System.Collections.Generic.List`1 or in short svcutil http://ServerName/ServiceName/Servic.svc?wsdl /ct:System.Collections.Generic.List`1 for more information go through this

Troubleshoot WCF service returning object with null fields

When you are working with WCF service for the first time, generally you will get this error for some reason. Here is the description of the error: WebServiceReference . ServiceClient client = new WebServiceReference . ServiceClient (); WebServiceReference . ImplementationRequest req = new WebServiceReference . ImplementationRequest (); req = client.GetRequest(); Here the Method GetRequest will return an object of ImplementationRequest. Everything will run without any error but the req object will contain all null fields/ majority null fields. Solution: Those nulls are due to error in generating the proxy for the Data Contract defined by the service. Verify that [DataMember] attribute tag is given for all the data fields and [DataContract] for the Class. If those attributes are missing, the object will be generated with null values. If all fields have the tags but the issue is not resolved, then the service reference should be re-added and the proxy should be re-generated. Then t

How to create a WCF Service Application

WCF is a buzz word now a days. Full form of WCF is 'Windows Communication Foundation'. Though it is not that much difficult to create a wcf service, sometimes its a bit tricky to configure the service correctly. I want to share simple steps to create and configure a WCF service here. But before to that we should go through some important terms of WCF. EndPoint: A service must have atleast one EndPoint. It is the component of the service that communicates with the client and provides the service operations. Address: This is the address of EndPoint. It may look like general Web URL. Bindings: Bindings are what define how an endpoint communicates with the outside world. Each endpoint must have a binding. The binding, which is simply a set of properties, defines things like the transport pattern, the security pattern, and the message pattern. Though most of these things are optional, binding should specify transport at least. Contracts: Contracts define format and structure of t