Client not able to access some methods of WCF Servicehttp://forums.asp.net/t/1765368.aspx/1?Client+not+able+to+access+some+methods+of+WCF+ServiceFri, 03 Feb 2012 10:41:54 -050017653684813883http://forums.asp.net/p/1765368/4813883.aspx/1?Client+not+able+to+access+some+methods+of+WCF+ServiceClient not able to access some methods of WCF Service <p>Hi,</p> <p></p> <p>I have designed a small WCF WebService. While I am trying to access its methods from the client; some are able to access but some are not. I am putting piece of code below:</p> <p></p> <p>[System.ServiceModel.ServiceBehaviorAttribute(InstanceContextMode=System.ServiceModel.InstanceContextMode.PerCall, ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Single)]<br> public class RestuarantService : IRestuarantService<br> { <br> public virtual GetRestaurantsResponse GetRestaurants(GetRestaurantsRequest request)<br> {<br> throw new System.NotImplementedException();<br> }<br> <br> public virtual void AddRestaurant(AddRestaurant request)<br> {<br> throw new System.NotImplementedException();<br> }<br> <br> public virtual void RateRestaurant(RateRestaurant request)<br> {<br> throw new System.NotImplementedException();<br> }</p> <p><br> }</p> <p></p> <p>From the above piece of code I am not able to access&nbsp;GetRestaurants() method from client. Couldnt understand the reason for this. Can anyone please help me in this.</p> <p></p> <p>Thanks &amp; regards,</p> <p></p> <p>Afreen</p> 2012-02-03T04:11:53-05:004814548http://forums.asp.net/p/1765368/4814548.aspx/1?Re+Client+not+able+to+access+some+methods+of+WCF+ServiceRe: Client not able to access some methods of WCF Service <p>Wherever you have&nbsp;<span>GetRestaurantsResponse defined, is the class annotated with a [DataContract] attribute and the properties annotated with a [DataMember] attribute?</span></p> <p><span>For example:</span></p> <pre> [DataContract] <span>public</span> <span>class</span> PurchaseOrder { <span>private</span> <span>int</span> poId_value; <span>// Apply the DataMemberAttribute to the property.</span> [DataMember] <span>public</span> <span>int</span> PurchaseOrderId { <span>get</span> { <span>return</span> poId_value; } <span>set</span> { poId_value = value; } } }</pre> <p><span>Without that, the call won't work because WCF will not understand the return type.</span></p> 2012-02-03T10:33:20-05:004814560http://forums.asp.net/p/1765368/4814560.aspx/1?Re+Client+not+able+to+access+some+methods+of+WCF+ServiceRe: Client not able to access some methods of WCF Service <p>Hi,</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Please make sure that <strong>GetRestaurants </strong>marked as [OperationContract] attribute and GetRestaurantsRequest &amp; GetRestaurantsResponse</p> <p>marked as [DataContract] attribute. Meanwhile you can also check your <strong> .svc?wsdl</strong> file wherther the &nbsp;type <strong>GetRestaurants </strong>exposed and also</p> <p>try with re-creating service reference from your client.</p> 2012-02-03T10:41:54-05:00