Click here to Skip to main content
15,891,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, Now i have to develop WCF service for my IOS aplication. My WCF level is just novie. I want to use JSON as parameter of my web service and my return value is string.
C#
 [ServiceContract(Namespace="")]
    public interface IService1
    {
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat=WebMessageFormat.Json,UriTemplate="/SaveUserData")]
        string  SaveUserData(NameValuePairs nvps);
}

 [DataContract]
    public class NameValuePair
    {
        [DataMember]
        public string name_obj
        {
            get;
            set;
        }

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

 [CollectionDataContract(Namespace = "")]
    public class NameValuePairs : List<NameValuePair> {
        public NameValuePairs()
        {
        }
    }

In My Service1.cs
C#
public class Service1 : IService1
 {
     public string SaveUserData(NameValuePairs nvps)
     {
         var columns = new StringBuilder();
         var parameters = new StringBuilder();
         string abc = "EMPTY SWEET";
         foreach (NameValuePair nvp in nvps)
         {
             abc = nvp.name_obj + " | " + nvp.value_obj;
         }

         return abc;
     }
}


I don't know how to set my endpoint in web.config.
I let my web service allow to access from IOS application and any other open source project such as "php,python". pls advice me how to modify my project endpoint? how to create the json to pass value to my web service from other projects ?

Best Rgds,
df
Posted
Updated 15-Oct-12 23:10pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900