WCF REST return single method as JSON and XML

前端 未结 3 1053
灰色年华
灰色年华 2020-12-09 00:32

I am using below Code for WCF Rest Services to get in JSON format

[OperationContract]   

[WebGet(UriTemplate = \"/GetOrderList?request={request}\", BodyStyl         


        
3条回答
  •  再見小時候
    2020-12-09 00:42

    You don't even need to specify the return type here , we have a property called automaticFormatSelectionEnabled for WebGet in end point behaviors as shown below. When you making your rest call request from client, you can specify the type as WebClient.Headers["Content-type"] = "application/json"; or WebClient.Headers["Content-type"] = "application/xml"; , service will detect the type and return the correct format you want ..

      
            
              
            
      
    

提交回复
热议问题