Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3615284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:21:16+00:00 2026-05-18T22:21:16+00:00

Hi all and thanks for your time in advance. I have a problem trying

  • 0

Hi all and thanks for your time in advance.

I have a problem trying to get to work a REST method under WCF. The method is POST, and I’m not able to retrieve the values sent from the Request.

This is how I declare the service according to an exemple from Microsoft about the WebInvokeAttribute Class:

[OperationContract]
    [WebInvoke( 
        Method = "POST" ,
        BodyStyle = WebMessageBodyStyle.Bare ,
        UriTemplate = "/sum?x={x}&y={y}" , 
        ResponseFormat = WebMessageFormat.Xml )]
    ResponseData Sum( string x, string y );

This is how I implemented this function in the class:

public ResponseData Sum( string x , string y )
    {
        ResponseData retorn = new ResponseData();

        int _x = 0;
        int _y = 0;

        try
        {
            _x = Convert.ToInt32( x );
            _y = Convert.ToInt32( y );

            retorn.Data = _x + _y + "";
        }
        catch ( Exception ex )
        {
            retorn.Data = "";
            retorn.Error = true;
            retorn.MsgError = ex.Message;
        }
        return retorn;
    }

ResponseData is a class implementing DataContract:

[DataContract]
public class ResponseData
{
    private bool error = false;
    private string msgError = "";

    [DataMember]
    public string Data { get; set; }
    [DataMember]
    public bool Error
    {
        get
        {
            return error;
        }

        set
        {
            error = value;
        }
    }
    [DataMember]
    public string MsgError
    {
        get
        {
            return msgError;
        }

        set
        {
            msgError = value;
        }
    }
}

As you can see, quite a simple example.

The thing is that it doesn’t work. Tha x and y parameters of the functions always have a value of null, doesn’t matter what I send along the request, so the returning message is always:

<responsedata xmlns="http://schemas.datacontract.org/2004/07/RestServiceProvaCrypto" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><data>0</data><error>false</error><msgerror></msgerror></responsedata>

So my question is, what I’m I doing wrong as I can’t obtain the values passed by the Request for x and y?

I’m working with VS 2008 and .Net 3.5.

Again, thanks for your time.

Ramon M. Gallart

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:21:16+00:00Added an answer on May 18, 2026 at 10:21 pm

    I dont know how much this will help you at this time, but according to me you are invoking the wrong CRUD concept for your problem.You should try to use the WebGet attribute and keep your UriTemplate the same, as in fact you are passing the data through a querystring.
    I would suggest..

    [OperationContract]
    [WebGet(
        BodyStyle = WebMessageBodyStyle.Bare ,
        UriTemplate = "/sum?x={x}&y={y}" , 
        ResponseFormat = WebMessageFormat.Xml )]
    ResponseData Sum( string x, string y );
    

    Hope this helps..

    Regards,
    vvn

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long-time follower, thanks so much for all your help over the years! I have
first of all thanks for taking your time! I'm a junior Dev, working with
Thanks for your help! I'd like to output all companyName entries that have uploads
First of all thank you for your time and sorry if some issues are
I am a newbie to VBS scripting. Thanks for all your comments! I fixed
First of all thanks in advance, this has been very frustrating and I'm hoping
First of all thanks for taking the time to look into this. I store
Hi all and thanks in advance. I am new to the NoSQL game but
Thanks to all that responded to my previous thread. There is still a problem
First off thanks to all the users who have made my android developing adventure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.