user2077700
user2077700

Reputation:

Get data from WCF service

Sorry, If It is a stupid question but I am new to WCF. I have a C# project in which, I am loading a XML document (contains name of students and Id) using Linq to xml and I have to get the associated data (their due date, amount and stuff ) from a WCF service (a link is given).

How do I get the associated data from WCF service ? Do I just right click and add service reference.

Upvotes: 1

Views: 3314

Answers (2)

daryal
daryal

Reputation: 14919

You need to define WCF methods with concrete types. You can not declare a method that returns anonymous objects, or interfaces.

Just create a DTO object representing you XML, and using Linq to Xml populate these DTOs. Then in your service methods, set the return types to these DTOs.

After adding the service reference, create a client proxy; like,

ServiceReference1.ClientProxy proxy = new ServiceReference1.ClientProxy();
var data = proxy.SomeMethod(someArguments);

Upvotes: 2

Swathi
Swathi

Reputation: 127

Yup, right click on the project, add service reference, configure A(address)B(binding)C(contract) in your project config file or through code, then create a proxy and call the webmethod.

example here

Upvotes: 0

Related Questions