WCF POST 方法无效

WCF POST Method is not working

我有一个 WCF Web 服务。我想使用 IIS post 一些值到 MS SQL 数据库中。 GET 方法有效。但是我找不到我的 POST 方法中哪里有错误。有没有人帮我看看我的错误在哪里......谢谢大家。这是我的代码...

    [OperationContract] //Interface
    [WebInvoke(Method = "POST", UriTemplate = "AddName", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
   int AddName(uName name);

     [DataContract]
   public class uName // a class in Interface
    {
        string name;
        [DataMember]
        public string setGetname
        {
            get { return name; }
            set { name = value; }
        }
    }

public int AddName(uName name) //My POST method in service class
    {

        int state = 0;
        SqlConnection connection = new SqlConnection(this.conStr);
        SqlCommand cmd = new SqlCommand();
        try
        {

            if (connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();

            }
            cmd = new SqlCommand("Insert into Table_1(kolon1) values(@name)", connection);
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Parameters.AddWithValue("@name", name.setGetname);
            cmd.ExecuteReader();
            state = 1;

        }
        catch (Exception ex)
        {
            throw ex;

        }
        finally
        {
            connection.Close();
            cmd.Dispose();
        }


        return state;
    }

已解决-> 我将 "BodyStyle = WebMessageBodyStyle.Bare" 更改为 "BodyStyle = WebMessageBodyStyle.Wrapped" ,它对我有用...谢谢大家...