Tuesday, October 25, 2011

Step 5 : Pass multiple body parameters in wcf rest



How pass multiple body parameters in wcf rest

using webinvoke method(Post or PUT)








Even If you have blank namespace  [DataContract(Namespace = "")] you have to put 
xmlns="" in the request body ... ( see the pictures below )
Whithout xmlns="" in the request body , problems can appear 






  [OperationContract]
        [WebInvoke(Method = "POST",
            ResponseFormat = WebMessageFormat.Xml,
            RequestFormat = WebMessageFormat.Xml,
            BodyStyle = WebMessageBodyStyle.Bare,
            UriTemplate = "testpersondatapost")]
        PersonData TestPersonDataPost(PersonData pd);


  [DataContract(Namespace = "")]
    public class PersonData
    {
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string User { get; set; }

        [DataMember]
        public string Email { get; set; }

        [DataMember]
        public string Password { get; set; }
    }


       public PersonData TestPersonDataPost(PersonData pd)
        {
            var response = new PersonData
            {
                Name = pd.Name,
                User = pd.User,
                Email = pd.Email,
                Password = pd.Password
            };
            
            return response;
            // return pd;
        }
























1 comment:

  1. Strikingly sports fans are potentially at an unbelievable reasonable position. You can locate the standard distractions channels on the web. Today you can watch international sporting events online with video gushing. medios independientes

    ReplyDelete