So im stuck on a few things in each part below, they are pretty trivial to most of you on stack so just wondering if I can get help with three issues I have in the below code segments the issues I have are:
My Operation contract looks like this:
[OperationContract]
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "")]
List<Tag> GetTagCollection();
#endregion
My datacontracts look like this:
[DataContract(Name="Student")]
public class Student
{
[DataMember(Name = "StudentID")]
public string StudentID { get; set; }
[DataMember(Name = "FirstName")]
public string FirstName { get; set; }
[DataMember(Name = "LastName")]
public string LastName { get; set; }
}
My service work looks like this:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class RawDataService : IReceiveData
{
public List<Group> GetGroupsCollection(string TagName)
{
List<Group> groups = (from g in _program.Groups // _program does not exist notsure what goes here
where
(from t in g.Tags where t.Name == TagName select t).Count() > 0
select g).ToList();
return groups;
}
1.Because
GetGroupsCollectionexpects aTagNameparameter, you’ll want to include that in your uri template:in order for it to be passed to the method when invoked by WCF REST. Uri Template (msdn)
2.Your contracts look ok, but you don’t need names when the name is the same as the class/member name. .Net will figure this out for you. But it doesn’t hurt…
3.Your service has to be pulling data from somewhere, right? For now, you could simply new up a collection of Groups to use for testing and return that. Database connections, ORM, etc. are probably beyond the scope of this question.
This should generate enough to play with:
Just replace
_program.GroupswithtempGroups.