Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10245 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > WCF > WCF DataContract Inheritance ...
Akiii

WCF DataContract Inheritance

 Code Snippet posted by: Akiii | Posted on: 6/1/2012 | Category: WCF Codes | Views: 853 | Status: [Member] | Points: 40 | Alert Moderator   


First we create WCF service application,

Iservice File Code :-
[ServiceContract]

public interface IService1
{
[OperationContract]
string GetData(clsCustomer2 objcustomer);
}

[DataContract]
public class clsCustomer1
{
[DataMember]
public string firstname { get; set; }

[DataMember]
public string lastname { get; set; }
}

[DataContract]
public class clsCustomer2: clsCustomer1
{
[DataMember]
public string salary { get; set; }
}


Then we write the implementation of the interface in the service class.
Service file code:-
public class Service1 : IService1

{
public string GetData(clsCustomer2 objcustomer)
{
return objcustomer.firstname + "---" + objcustomer.lastname + "---" + objcustomer.salary;
}
}



Then I created a console client and tested the service. I added a service reference of the above service and created a proxy class.
Client code :-
class Program

{
static void Main(string[] args)
{
Service1Client objClient = new Service1Client();

clsCustomer2 objc = new clsCustomer2();
objc.firstname = "Akiii";
objc.lastname = "lethal";
objc.salary = "10";

string str = objClient.GetData(objc);

Console.WriteLine(str);
Console.ReadLine();
}
}



Try this and if you find any problem in the above code, please let me know !


Thanks and Regards
Akiii
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 2:50:13 AM