Reputation: 463
my WCF service get request looks like below:
so based on param op, response type should change. How to accomplish this?
Upvotes: 1
Views: 1160
Reputation: 364389
Here you have complex article about setting response in different formats. If you are using WCF 4 I would definitely think about setting automaticFormatSelectionEnabled="true" in WebHttpBehavior
. It will automatically choose response format (XML or JSON) based on client's HTTP Accept header.
Upvotes: 2
Reputation: 6003
One way would be the WebGetAttribute
: http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webgetattribute.aspx
public class MyService
{
[OperationContract]
[WebGet(UriTemplate = "search?q={keyword}&op=xml")]
string GetXml(string keyword);
[OperationContract]
[WebGet(UriTemplate = "search?q={keyword}&op=json")]
string GetJson(string keyword);
}
note: above not tested
Upvotes: 2