.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

WCF Tip: Using Properties in Service Contracts

Posted By: Amit Mehra     Posted Date: December 14, 2009    Points: 2   Category :WCF
you'll notice all of the Service Contracts are implemented with interfaces containing only methods. For the longest time I thought that's all that was supported, until I thought about it a little more. In C# land, properties are simply wrappers around a get method and set method, so why wouldn't we be able to use properties in a service contract? Well the answer is we can.

View Complete Post

More Related Resource Links

All data in class properties disappear across WCF service

Hi, I have a class that i share betwee silverlight client and wcf service. I populate properties of the class with real data from the client, to be used in the server. I use debugger to step through the code when the call gets to the server, all the data ara gone and are replaced with null. All DateTime value change to 1/1/1001. But if pass primitive types such as int, string, no problem. This is happening only on one machine, but not on ther machine. Can someone tell me what is going on here? Thanks in advance

How to expose app.config or binding properties for web service

I have a project that consumes a web service, which is then bundled into a windows service and a deployment project.  Both the project consuming the web service (I'll call that the vendorcontrol) and the service project have app.config files in the project structure, but when I compile and deploy, the settings for the vendorcontrol are not accessible in the resulting project.exe.config file.  How would I make this happen?

can we use optional params in C# while defining service contracts?


I mean can I do something like this:

List<String> GetEmployees(String EmployeeId,  String DepartmentID= "00");

and then implement it the same way as below

List<String> GetEmployees(String EmployeeId, String DepartmentID= "00")




I tried this, but it didn't work. Its always expecting DepartmentID when I tried to use invoke 'GetEmployees' using service reference.

Web Service - Different Operation Contracts calling the same method

I would like to know how could I define two operation contracts (JSON, XML) which call to the same method; I have defined web and basic http bindings for all the Operation Contracts in the way that they could be called from HTTP requests (jQuery) and from Silverlight.

This first example works because the methods have different number of input parameters. But I need to add the attribute name to the Operation Contract.

        [WebInvoke(Method = "POST",
            UriTemplate = "1/json/getRegions",
            ResponseFormat = WebMessageFormat.Json)]
        RegionListOutput GetRegionList(int countryID, int other);

        [OperationContract(Name = "getRegionsXML")]
        [WebInvoke(Method = "POST",
            UriTemplate = "1/xml/getRegions",
            ResponseFormat = WebMessageFormat.Xml)]
        RegionListOutput GetRegionList(int countryID);


Public properties of collection derived classes are not deserialized in REST wcf service


I have Restful wcf service that returns the following class, but the Total and Count fields become 0 when it reaches the client side. But they have the correct values on the server side.

 public class Groups : List<Group>
private int total;
private int start;

/// <summary>
/// Total number of Groups in the result set irrespective of the paging
/// </summary>

Windows Service Applications Tutorials

You can easily create services by creating an application that is installed as a service. For example, suppose you want to monitor performance counter data and react to threshold values. You could write a Windows Service application that listens to the performance counter data, deploy the application, and begin collecting and analyzing data.

Realizing a Service-Oriented Architecture with .NET

This article is meant to be a practical discussion guide to building a .NET application in a service-oriented architecture. We will consider real-world goals, real-world obstacles, and experience-based solutions. I quickly concede the approaches discussed here are not exhaustive or infallible. This paper is focused on application development, not application integration. We will specifically consider architectural issues and component design issues.

The Potential of Web Services

Automatic vs Explicit Properties

If the reason that motivated the change from automatically implemented property to explicitly implemented property was to change the semantics of the property then you should evaluate whether the desired semantics when accessing the property from within the class are identical to or different from the desired semantics when accessing the property from outside the class.

Web Service for uploading documents into SharePoint

WS UploadService is a web service written for Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0 and is meant for uploading documents into SharePoint. I have just uploaded the zip file to GotDotNet.com so it will take some time before the zip file appears in the list of downloads. For the time being, you can download the zip file from the following location

Dependency Properties

When you begin to develop appliations with WPF, you will soon stumble across DependencyProperties. They look quite similar to normal .NET properties, but the concept behind is much more complex and powerful

Creating and Using an ASP.NET Web Service in Visual Web Developer

In addition to letting you create Web pages, Microsoft Visual Studio also lets you create Web services that use ASP.NET XML. Creating a Web service in Visual Studio is similar to creating a Web page. You can also use the Microsoft Visual Web Developer Web development tool to reference and use Web services that are in a Visual Web Developer solution, on your local computer or in a local or external UDDI directory. In this walkthrough, you will create the Web service in one solution and use it in another.

Tasks illustrated in this walkthrough include:

Creating a simple XML Web service in Visual Web Developer.

Creating a separate Web site that uses the Web service.

Xml File Methods and Properties

Method and Properties of XmlTextWriter class:
The XmlWriter class is a base class that outputs an XML data structure. It has methods to sequentially write XML elements in a proper hierarchy to create an XML file or other types of output streams. The System.Xml namespace provides support for the XmlWriter. It must be imported to the ASP.NET page with the directive

<%@ Import Namespace="System.Xml" %>

The XmlTextWriter

XmlWriter is an abstract class that is implemented as an extended XMLTextWriter class. The XmlTextWriter writes a sequence of XML nodes one element at a time. Output can be written to an XML file, although other streams of output data can be produced. It can create a new file or overwrite an existing file. Its non-cached writing techniques provides very fast generation of an output stream.

AutoGenerateSelectButton="False" ignored when using Domain Service


Crosspost from RIA Services forum: http://forums.silverlight.net/forums/t/196466.aspx

I'm creating a Dynamic Data application in VS2010 and have recently switched to using a Domain Service to give greater control over the data presented to the client. I've noticed that the AutoGenerate<Action>Button attributes on my GridView are being ignored. The presence of the Edit and Delete buttons appear to be contingent on the existence of Update and Delete methods on the partial classes autogenerated in the Domain Service, but i'm not seeing how to control the generation of the Select button. Is there a way to control this from within the Domain Service class?

Any framework for creating a job scheduler service?


Just curious to know if there was any official Microsoft code blocks, classes, or such for writing a service that runs other assemblies or WCF services?  That can be configured easily from a web page, pre-coded, for running tasks at certain times on certain recurring intervals?  I've already built one but am open to anything done better- which I'm sure there is.  Thanks!!!

Convert WCF service to self hosting application


 I created project as a  WCF Service application and now according to recuriment that needs to be converted as a self hosting application

How can i do this?

Converting WCF service app to Self hosting app?

WCF Data Service to JSON example? v4


I would like to take WCF Data Service and produce JSON output to consume on various mobile apps.

Can anyone give me a how-to on the JSON part?  I.e., what is different than normal XML outut?



Problem to obtain client IP on web service



I'm having problems to obtain the client IP on web service. Here's my scenario:

One server with Windows 2003, hosting the web service using .Net Framework 2.0, with IP and host name ServerTransaction.
Other server with Windows 2003, hosting a web application using .Net Framework 2.0, that consuming the web service on  ServerTransaction, with IP and host name ServerApplication.
Many other computers on the local network (IPs:,,, ...) acessing the web application on ServerApplication.

On the code of the web service I've tried to use HttpContext.Current.Request.UserHostAddress or HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") or HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FORR"), but always I can only get the IP of ServerApplication (

Any idea or tip?

Thanks and sorry for my bad english.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend