You must Sign In to post a response.
  • Category: Webservices

    Passing arguments corresponding to parameters in webservice methods

    Hi,
    I have use the following codes in webservice file
    CMSDB.cs (database function file)
    public static List<Complaint> SearchComplaint(string queryType, string c, string status)
    {
    }
    And have use in Service1.svc.cs
    public List<Complaint> SearchComplaint(string queryType, string c, string status)
    {
    List<Complaint> cmp = CMSDB.SearchComplaint(queryType,c,status);
    return cmp;
    }
    And in interface file. I have used following codes:
    [OperationContract]
    List<Complaint> SearchComplaint(string queryType, string c, string status);

    On c# windows application, I am using the following codes
    CMS.ServiceReference1.Complaint[] res = CMSGlobals.service.SearchComplaint();
    But it's showing error- No overload for methos'SearchComplaint' takes 0 arguments
    Please suggest what arguments should I use here?
  • #756723
    Hai DP Sharma,
    If you see the Service1.cs class, the defintion of the method is as below:

    public List<Complaint> SearchComplaint(string queryType, string c, string status)

    So the method SearchComplaint needs the parameter queryType and a string c and then status also as string. So total it needs 3 parameters.
    After that it will return the result as the List of type Complaint.
    So when you are consuming the service, first you need to create the proxy class object based on the same datatype as below:

    CMS.ServiceReference1.Service1Client proxy = new CMS.ServiceReference1.Service1Client();
    List<Complaint> complaints= new List<Complaint>();
    complaints = proxy.SearchComplaint("queryType","c", "status");

    So here you need to pass the values for the parameters to get the list of complaints.
    And then you can use it.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • Sign In to post your comments