Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. implementing REST in WCF

implementing REST in WCF

Scheduled Pinned Locked Moved WCF and WF
csharpwcfjsonquestion
4 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    priy
    wrote on last edited by
    #1

    Hi, can anyone please tell me how do i implement the following service as a REST service in WCF.I am using .net3.0,VS2005. also please let me know if anything else has to be installed. thanks in advance.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.ServiceModel;

    namespace DLL1 {
    [ServiceContract]
    public interface ICalc{
    [OperationContract]
    int Addn(int a, int b);

        \[OperationContract\]
        int Mult(int a, int b);
    }
    
        public class Calculator:ICalc{
            public int Addn(int a, int b) {
                return (a + b);
            }
    
            public int Mult(int a, int b) {
                return (a \* b);
            }
    }
    

    }

    P 1 Reply Last reply
    0
    • P priy

      Hi, can anyone please tell me how do i implement the following service as a REST service in WCF.I am using .net3.0,VS2005. also please let me know if anything else has to be installed. thanks in advance.

      using System;
      using System.Collections.Generic;
      using System.Text;
      using System.ServiceModel;

      namespace DLL1 {
      [ServiceContract]
      public interface ICalc{
      [OperationContract]
      int Addn(int a, int b);

          \[OperationContract\]
          int Mult(int a, int b);
      }
      
          public class Calculator:ICalc{
              public int Addn(int a, int b) {
                  return (a + b);
              }
      
              public int Mult(int a, int b) {
                  return (a \* b);
              }
      }
      

      }

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You would be better off upgrading to .NET 3.5 - it's a whole lot easier (and you can get the Express editions free). Your code would end up like this:

      using System;
      using System.Collections.Generic;
      using System.Text;
      using System.ServiceModel;
      namespace DLL1 {
      [ServiceContract]
      public interface ICalc{
      [WebGet]
      [OperationContract]
      int Addn(int a, int b);
      [WebGet]
      [OperationContract]
      int Mult(int a, int b);
      }
      }

      The bits in Bold are the bits you need to add to make this RESTful. BTW - you should also use webHttpBinding.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      P 1 Reply Last reply
      0
      • P Pete OHanlon

        You would be better off upgrading to .NET 3.5 - it's a whole lot easier (and you can get the Express editions free). Your code would end up like this:

        using System;
        using System.Collections.Generic;
        using System.Text;
        using System.ServiceModel;
        namespace DLL1 {
        [ServiceContract]
        public interface ICalc{
        [WebGet]
        [OperationContract]
        int Addn(int a, int b);
        [WebGet]
        [OperationContract]
        int Mult(int a, int b);
        }
        }

        The bits in Bold are the bits you need to add to make this RESTful. BTW - you should also use webHttpBinding.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        P Offline
        P Offline
        priy
        wrote on last edited by
        #3

        but if i want to implement it using .NET 3.0 then how do i do it?

        P 1 Reply Last reply
        0
        • P priy

          but if i want to implement it using .NET 3.0 then how do i do it?

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Well, you've got a lot more work ahead of you then. This[^] article might be of help - you really need to download the WCF technology samples[^] and have a look at them.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups