Reputation: 461
I'm new to wcf services development. I have the following problem: I'm creating wcf-service with URI template like this:
[OperationContract, WebGet(UriTemplate = "/EmpDetails/command/?command=SaveDetails&id={id}&data{empid:{EmpID},EmpName:{EmpName},EmpAge:{EmpAge}}"
How can I access these values to save details?
another thing is i want this URL to be used to save details.
http://12.154.21.23:8888/EmpDetails/command/?command=SaveDetails&data={empid:Test,EmpName:TestName,EmpAge:26}
Upvotes: 1
Views: 5566
Reputation: 1091
You need to create a class somewhere in service:
[DataContract]
public class Data
{
[DataMember]
public int EmpID {get;set;}
[DataMember]
public string EmpName{get;set;}
[DataMember]
public string EmpAge {get;set;}
}
Next, add this to your wcf service interface:
[OperationContract]
[WebGet(UriTemplate = "/EmpDetails/command/?command=SaveDetails&id={id}&data{EmpID:{EmpID},EmpName:{EmpName},EmpAge:{EmpAge}}")]
void SaveDetails(int id, Data data);
and finally, add code below to class implementing wcf service interface:
public void SaveDetails(int id, Data data)
{
//do smt
}
Upvotes: 3