WCF REST return single method as JSON and XML

前端 未结 3 1059
灰色年华
灰色年华 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 01:02

    I was having the same issue. We provided the solution by creating two endpoints one for XML and the other for JSON.

    Make sure you remove all attributes from the Service Interface. Don't specify the RequestFormat or ResponseFormat to control XML or JSON. Let it be controlled by the endpoint.

    Service Web.Config changes.

    
    
      
    
        
          
        
        
          
        
    
              
    
    
    
    
    

    Hope this helps.

提交回复
热议问题