convert a WCF Service, to a RESTful application?

前端 未结 4 2045
北荒
北荒 2021-01-02 04:45

Hey im not getting anywhere with turning wcf into a restful service. So I was wondering if some one can take the basic code when you start a WCF Service application here:

4条回答
  •  离开以前
    2021-01-02 05:04

    As you had mentioned, this is a new project, so maybe a redirect might help make the process a little more simple?

    Here is an MSDN article about what you are asking.

    However, I especially suggest looking at ServiceStack to create a RESTful service, as it makes the process extremely easy. WCF definitely does not provide an easy means to accomplishing this. They overcomplicate it in this case IMO.

    That would be where I would go with this instead, if this is indeed the beginnings of a project

    A more direct answer comes from This article that is a bit older, but can probably help both understand REST, and how to implement it in WCF. And is to specify your GET/POST/PUT/DELETE in a Web[Type]Attribute

    [WebGet(UriTemplate = @"Data?value={value}")]
    [OperationContract]
    string GetData(int value);
    

    Also, you will need to do this in your application's .config (Again for the older, MSDN article by Skonnard)

    
       
         
            
                
            
         
         
            
                
                    
                
            
         
      
    
    

    Which would translate into your config as:

    
    
      
        
        
          
          
            
          
        
        
      
    
    
      
        
          
          
          
          
        
      
      
          
               
          
      
    
    

    Then, you will probably need to add an address attribute to the endpoint so it knows where to look.

提交回复
热议问题