What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 25300 |  Welcome, Guest!   Register  Login
 Home > Forums > WCF > Why do we need an Interface in Web Service ? ...
Akiii

Why do we need an Interface in Web Service ?

Replies: 7 | Posted by: Akiii on 3/13/2012 | Category: WCF Forums | Views: 1741 | Status: [Member] | Points: 10  


Hi friends,
When we are using WCF or normal web-service, by default an interface is created in the both the technologies. Why do we need an interface in there ? Can't we just use a Class instead of that ?

Please do share some knowledge on this matter !



Thank and Regards
Akiii


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Hmanjarawala
Hmanjarawala  
Posted on: 3/14/2012 2:23:58 AM
Level: Bronze | Status: [Member] | Points: 50

Resolved

Hi Akii,

in dotnet interfaces are used for describing behaviour.
WCF, Web-services and remoting this all technology uses RPC (Remote Procedure Calling) behaviour.
in RPC there must be some common binding which shared by client and server.

if you use classes instead of interface, you've share your resultatnt dll file to client also.
hence your logic goes to client side, which is not good practice. that's why we are using interfaces.


Mark this as answer, if it helps you...........

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sksamantaray
Sksamantaray  
Posted on: 3/14/2012 2:39:44 AM
Level: Silver | Status: [Member] | Points: 25

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

CGN007
CGN007  
Posted on: 3/14/2012 5:40:46 AM
Level: Silver | Status: [Member] | Points: 25

@Himanshu
Nice explanation..Keep sharing...!!!

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Akiii
Akiii  
Posted on: 3/15/2012 12:29:29 AM
Level: Bronze | Status: [Member] | Points: 25

Hi Himanshu ,

Thanks for your answer. You want to say that through Interfaces we are describing the behaviors ?
Now when a RPC call is made, interfaces are used to connect that to our system ......it is something like that ?
the servicecontract attribute can be only applied to an interface, why not an abstract class ?

Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Akiii
Akiii  
Posted on: 3/15/2012 12:36:07 AM
Level: Bronze | Status: [Member] | Points: 25

Thanks Sanjay for your post, please refer to the questions asked above to Himanshu. If you know the answer then please do share !


Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Hmanjarawala
Hmanjarawala  
Posted on: 3/15/2012 12:41:08 AM
Level: Bronze | Status: [Member] | Points: 50

Resolved

Hi Akiii,

1st of all using interface as shared medium between client and service, we can hide our businesslogic from client...
here i means that if you use concrete classes then client may generate code from your dlls (through ILDASM.exe or other tools available...).
and reason for not using abstract class for same because multiple inheritance is not supported.

that's why................

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Akiii
Akiii  
Posted on: 3/15/2012 4:03:28 AM
Level: Bronze | Status: [Member] | Points: 25

Thank you Himanshu ......for giving a good explanation !

Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

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/21/2013 1:09:31 PM