locked
can anyone consume this service? RRS feed

  • Question

  • User-1799911463 posted

    This is my service. Any other better way to design this? can any one consume this service i.e. javascript,php, Java.

    Interface

    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        datas GetData(input ip);      
    }
    [CollectionDataContract]
    public class datas : List<output>
    {
        public datas() { }
        public datas(List<output> datas) : base(datas) { }
    }
    [DataContract]
    public class output
    {
        [DataMember]
        public string city
        {
            get;
            set;
        }      
    }
    [DataContract]
    public class input
    {
    [DataMember]
        public string id
        {
            get;
            set;
        }   
    }

    service implementation

    public class Service1 : IService1
    {
        public datas  GetData(input ip)
        {            
               datas collection = new datas();                             
               tbTemp = con.GetDataTable(query);                          
               foreach (DataRow dtRow in tbTemp.Rows)
               {
                   output op = new output();
                   op.city = dtRow[0].ToString();                  
                   collection.Add(op);
               }               
               return collection;           
        }      
    }

    or should i go for WCF RESTful service and like that?

    Wednesday, March 6, 2013 7:12 AM

Answers

  • User-1000095884 posted

    Hi,

    The code snippets you posted seem not for a Restful service, there are multiple HTTP methods which are use full when creating Rest Services(GET,PUT,DELETE etc.), if you want to call your wcf service from JQuery/Javascript, you can refer a sample in blow blog.

    #Steps to Call WCF Service using jQuery

    http://pranayamr.blogspot.ca/2010/12/steps-to-call-wcf-service-using-jquery.html

    If you want to create a Restfull service and consume it from Javascript, you can find an example in blow link.

    #Create REST service with WCF and Consume using jQuery

    http://pranayamr.blogspot.ca/2011/03/rest.html

    Hope this helps.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 7, 2013 10:43 PM

All replies

  • User-933257319 posted

    It will work cross tehcnology as the class datas will be there in the wsdl and available on client application ...

     

     

    Wednesday, March 6, 2013 7:37 AM
  • User-1799911463 posted

    Could you provide few more details?

    1. is my service RESTful service?

    2. If not, shall i go for RESTful for more efficient  ? (or is the current design efficient?)

    Wednesday, March 6, 2013 7:50 AM
  • User-1000095884 posted

    Hi,

    The code snippets you posted seem not for a Restful service, there are multiple HTTP methods which are use full when creating Rest Services(GET,PUT,DELETE etc.), if you want to call your wcf service from JQuery/Javascript, you can refer a sample in blow blog.

    #Steps to Call WCF Service using jQuery

    http://pranayamr.blogspot.ca/2010/12/steps-to-call-wcf-service-using-jquery.html

    If you want to create a Restfull service and consume it from Javascript, you can find an example in blow link.

    #Create REST service with WCF and Consume using jQuery

    http://pranayamr.blogspot.ca/2011/03/rest.html

    Hope this helps.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 7, 2013 10:43 PM
  • User-1799911463 posted

    Thanks for your guidelines..

    Thursday, March 7, 2013 11:59 PM