How to replicate parameter passing to a rest service like WCF

Answered

Comments

5 comments

  • Avatar
    Anton Venema

    Hi George,

    Try this:

        client.Send(new SendArgs(HttpMethod.Post, "/user/123")

        {

            DataJson = Json.Serialize(myCustomClass)

        });

    There's also DataBytes (for sending binary data). On the server, you access them using RequestDataJson and/or RequestDataBytes:

        public static void SaveUser(object sender, TheRestEventArgs e)

        {

            // e.RequestDataJson, e.RequestDataBytes

        }

     

    0
    Comment actions Permalink
  • Avatar
    George Nicolaidis

    Hi, thank you for response,

    The proposed solution works only for the post method, if you try to use the get method you get an error back, but I guess its fine to use the post method even if you only intended to get back some info. Also the e.RequestDataJson method seems to be obsolete since only e.RequestJson is available.

    Additionally, I am having a real problem debugging the service in visual studio 2013. I cannot force the debugger to enter the service for stepping through the code whatever I have tried. I have included the <compilation debug="true"> entry into the web configuration file, but still no result.

    Are they any other steps to consider to be able to debug the service?

    Thank you for your kind attention and consideration.

     

    Regards,

     

    George

     

     

    0
    Comment actions Permalink
  • Avatar
    Anton Venema

    Hi George,

    Technically, GET requests are not supposed to have a body, but we don't prevent this in TheRest. It would be a bit unconventional, but you could do it. (http://stackoverflow.com/questions/978061/http-get-with-request-body)

    I really have no idea why Visual Studio wouldn't be hitting your breakpoints. Try selecting your web project in Visual Studio, hit F4, and change "Always Start When Debugging" to True. This link might be helpful as well:

    http://stackoverflow.com/questions/4728243/visual-studio-some-breakpoints-not-breaking

    Regards,

    Anton

    0
    Comment actions Permalink
  • Avatar
    George Nicolaidis

    Hi Anton,

     

    About breakpoints, I have tried your suggestion, the setting was already on. You can test the NET.Client.2012 example from your samples you have included with the distribution to replicate the problem.

    0
    Comment actions Permalink
  • Avatar
    Anton Venema

    Weird. I just tried it, and it hit the breakpoint immediately. The only other thing I could suggest it to make certain that both projects (client and server) are attached to the debugger. Right-click on the server project and select Debug -> Start new instance, then do the same for the client project.

    0
    Comment actions Permalink

Please sign in to leave a comment.