0
votes

I am creating a WCF Service. There are multiple Operation Contract for the service. Among them, only one [Operation Contract] will be as JSON data.

For Example:--- Service Name: IAdmin.cs

[OperationContract]
DataSet GetReport(int userID);

[OperationContract]
[WebInvoke(Method="GET", UriTemplate="/getDetails?name={name}", ResponseFormat = WebMessageFormat.Json, BodyStyle=WebMessageBodyStyle.Wrapped)]
Admin_UserDetails getUserDetails();

In the above code, the first [Operation Contract] will be returning XML message format. The second one will be returning in JSON format.

Now, my question is that will I have to create another service for the JSON [Operation Contract] or is it ok to write in the same service?

1

1 Answers

0
votes

Multiple endpoints and bindings on a single service is actually a strength of the WCF. I think this MSDN article will help you.