• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

wcf, and consume <list>

try to consume wcf List <string>, please review the attachment.
  • 2
1 Solution
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:

The method GetStateList is not specified as [OperationContract] I think.

Follow this tutorial to modify whatever is missing in your wcf service code-

And this also-
solution1368Author Commented:
I don't add the operation contract there because I thought it will be easier for experts to understand what I am trying to do. For sure, the code is working and I tested it in WCF test client already. I just don't know how to consume it :-( in List.

Both url you mentioned, I already read long time ago. It does not help me to resolve this question.

Miguel OzSoftware EngineerCommented:
To get the list:
ServiceRef.ServiceClient sc = new ServiceRef.ServiceClient();
List<State> states =  sc.GetStateList();

Open in new window

and you consume the states variable in your code

Regarding dropdown binding, typically you build a IEnumerable<SelectListItem> as per link below:

Keep in mind that for building the dropdown items Text = Value = item.stateName  , because you only have one property in your State object.
solution1368Author Commented:
It is consumed in c# asp.net
Please show me the code
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now