Given a contract such as:
[ServiceContract] public interface IService { [OperationContract] [WebGet(UriTemplate = 'GetData/{id}.{format}')] ResponseData GetData(string id, string format); }
Is there a way to get the service to respond with json when requested as: /GetData/1234.json, xml when requested as /GetData/1234.xml and still be available as a proper soap service at some other url, with a strongly typed wsdl contract?
Using a Stream as the return value for GetData is not workable, as though it fufills the first two requirements, wcf can’t create a full wsdl specification as it has no idea what the contents of the resultant Stream will be.
You should have two separate methods which take id and format (and they would call a shared implementation that returns
ResponseData) which have differentWebGetattributes:For the SOAP endpoint, you should be able to call either method, but you are going to have to have a separate
ServiceHostinstance hosting the implementation of the contract.