Consider a WCF service that returns some text that you entered. The service has a contract called IService1 and an operation called GetData. When we run the service in our test client, we see:
The code for this is:
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace Carl.TestWCF { [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); } }
Let’s say we want the service and operation to be different to what the WCF consumer will see. In order to do this, we decorate our methods below with:
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace Carl.TestWCF { [ServiceContract(Name = "Return What Was Entered")] public interface IService1 { [OperationContract(Name ="Do The Returning")] string GetData(int value); } }
When we run our test client now, we can see the names have changed:
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET'S KEEP LEARNING TOGETHER.
CARL