0

Hi, How to call WCF Service from MVC web api and bind the service model into MVC model? Can you please help ?????

[DataContract]
public class Employee
{
    [DataMember]
    public int Id { get; set; }
    [DataMember]
    public string Name { get; set; }
    [DataMember]
    public int Age { get; set; }
}

This is the employee class

EndpointAddress endpointAddress = new EndpointAddress(ConfigurationManager.AppSettings["ServiceKey"]);
string endpointConfigurationName = "SampleSerVice";
ClassProxy obj = new ClassProxy(endpointConfigurationName, endpointAddress);

var result = obj.GetEmployeeName();

result returns the list of employee, but how to bind this to MVC Model

1

1 Answer 1

0

First of all you need to create WCF Service.

After that you will had to add the ServiceBase Reference in your project. and then go to the link which is provided by the WCFService. and then Add the Service by giving Proper name. After that you need to add the endpoints of the WCF Service which you can find in the Appconfig in the Project where you have added the ServiceBase Reference. Copy the binding name=" " and End points from the AppConfig and paste it in the Web Config. You can Access the WCF Service and to use the Service You need to create the instance of it and then whatever models or methods you need to access it.

Sign up to request clarification or add additional context in comments.

3 Comments

Acutully the WCF service calling part is success, now problem is am not able to bind the WCF model to MVC model. How to solve this ?
Copy the binding name=" " and End points from the AppConfig and paste it in the Web Config. this way you can bind the WCF Service
This way i can only get only one json string right. How to map that model into my mvc model. thats my question ?????

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.