Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My webservice GETcompletion1 is not firing the code is somthing like this
C#
using System;
using System.Collections.Generic;
using System.Web.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AutoComplete : WebService
{
    public AutoComplete()
    {
    }

    [WebMethod]
    public string[] GetCompletionList(string prefixText, int count)
  {
        if (count == 0)
        {
            count = 10;
        }
        DataTable dt = GetRecords(prefixText);
        List<string> items = new List<string>(count);

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string strName = dt.Rows[i][0].ToString();
            items.Add(strName);
            
        }
        return items.ToArray();
    }

    public DataTable GetRecords(string strName)
    {
        DataSet objDs = new DataSet();
        
            SqlConnection con = new SqlConnection("Data Source=USER-PC\\SQLEXPRESS;Initial Catalog=medicalvoyager;Integrated Security=True");
            //con.Open();
            //SqlCommand cmd = new SqlCommand();
            //cmd.Connection = con;
            //cmd.CommandType = System.Data.CommandType.Text;
            SqlCommand com = new SqlCommand("Select Group_name from groups where Group_name like '%'+@Name+'%'  ",con);
            //cmd.CommandText = "Select Group_name from groups where Group_name like '%'+@Name+'%'";
           com.Parameters.AddWithValue("@Name", strName);
            SqlDataAdapter dAdapter = new SqlDataAdapter();
            dAdapter.SelectCommand = com;
            con.Open();
            dAdapter.Fill(objDs);
            con.Close();
        return objDs.Tables[0];   
        }
    [WebMethod]
    public string[] GetCompletionList1(string prefixText,int count)
    {
        if (count == 0)
        {
            count = 10;
        }
        DataTable dt = GetRecords1(prefixText);
        List<string> items1 = new List<string>(count);

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string strName = dt.Rows[i][0].ToString();
            items1.Add(strName);

        }
        return items1.ToArray();
    }

    public DataTable GetRecords1(string strName)
    {
        DataSet objDs = new DataSet();

        SqlConnection con = new SqlConnection("Data Source=USER-PC\\SQLEXPRESS;Initial Catalog=medicalvoyager;Integrated Security=True");
        con.Open();
       // SqlCommand cmd = new SqlCommand();
       // cmd.Connection = con;
       // cmd.CommandType = System.Data.CommandType.Text;
        SqlCommand com = new SqlCommand("Select mvc_countryname from medvoyager_country where mvc_countryname like '%'+@Name+'%' ", con);
       // cmd.CommandText = "Select Group_name from groups where Group_name like '%'+@Name+'%'";
        com.Parameters.AddWithValue("@Name", strName);
        SqlDataAdapter dAdapter = new SqlDataAdapter();
        dAdapter.SelectCommand = com;
        con.Open();
        dAdapter.Fill(objDs);
        con.Close();
        return objDs.Tables[0];
    }


    }


so is it the problem with webmetod?
Posted

Can I use more than one web method in a single webservice class
Yes, you can have multiple WebMethods in a single web service.

My webservice GETcompletion1 is not firing the code
You sure that you updated the WebService reference in your web project? Is that referring to latest code?
Try Visual Studio DEBUGGER, put break point on the workflow start point and then do F11 to see how things are happening. If you don't land up in the method, most probably your web reference is not up-to-date (assuming all other implementation and method call are correctly done).

Check!
 
Share this answer
 
Comments
Arjun YK 2-Jul-12 3:04am    
I've tried the same thing what u told sir. Getcompletionlist methoed is working in a file. But the method Getcompletionlist1 is not firing i checked it with a break point also.
Can I use more than one web method in a single webservice class

Yes, You can have more than one WebMethod in single webservice class.

My webservice GETcompletion1 is not firing

there is no web method called GETcompletion1 you need to call GetCompletionList1, Put break point inside the method and check whether it firing or not and also better to have exception handling.

Few steps you can follow.

Clean the solution and delete the web reference.
Add the web reference again and build the solution.
If any build errors, fix those and check what you have given as ServiceMethod and <code>ServicePath in AutoCompleteExtender

ServiceMethod="GetCompletionList1" ServicePath="~/YourWebService.asmx"
 
Share this answer
 
v2
Comments
Arjun YK 2-Jul-12 3:15am    
I've mistyped it the method name is GetCompletionList1. The SAME I'm calling in the Autocomplete extender. its not firing the event..
DamithSL 2-Jul-12 3:53am    
Please check updated answer
yes u can add this code for doing following work done
C#
using System;
using System.Collections.Generic;
using System.Web.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AutoComplete : WebService
{
    public AutoComplete()
    {
    }
 
    [WebMethod]
    public string[] GetCompletionList(string prefixText, int count)
  {
        if (count == 0)
        {
            count = 10;
        }
        DataTable dt = GetRecords(prefixText);
        List<string> items = new List<string>(count);
 
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string strName = dt.Rows[i][0].ToString();
            items.Add(strName);
            
        }
        return items.ToArray();
    }
 
    public DataTable GetRecords(string strName)
    {
        DataSet objDs = new DataSet();
        
            SqlConnection con = new SqlConnection("Data Source=USER-PC\\SQLEXPRESS;Initial Catalog=medicalvoyager;Integrated Security=True");
            //con.Open();
            //SqlCommand cmd = new SqlCommand();
            //cmd.Connection = con;
            //cmd.CommandType = System.Data.CommandType.Text;
            SqlCommand com = new SqlCommand("Select Group_name from groups where Group_name like '%'+@Name+'%'  ",con);
            //cmd.CommandText = "Select Group_name from groups where Group_name like '%'+@Name+'%'";
           com.Parameters.AddWithValue("@Name", strName);
            SqlDataAdapter dAdapter = new SqlDataAdapter();
            dAdapter.SelectCommand = com;
            con.Open();
            dAdapter.Fill(objDs);
            con.Close();
        return objDs.Tables[0];   
        }
    [WebMethod]
    public string[] GetCompletionList1(string prefixText,int count)
    {
        if (count == 0)
        {
            count = 10;
        }
        DataTable dt = GetRecords1(prefixText);
        List<string> items1 = new List<string>(count);
 
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string strName = dt.Rows[i][0].ToString();
            items1.Add(strName);
 
        }
        return items1.ToArray();
    }
 
    public DataTable GetRecords1(string strName)
    {
        DataSet objDs = new DataSet();
 
        SqlConnection con = new SqlConnection("Data Source=USER-PC\\SQLEXPRESS;Initial Catalog=medicalvoyager;Integrated Security=True");
        con.Open();
       // SqlCommand cmd = new SqlCommand();
       // cmd.Connection = con;
       // cmd.CommandType = System.Data.CommandType.Text;
        SqlCommand com = new SqlCommand("Select mvc_countryname from medvoyager_country where mvc_countryname like '%'+@Name+'%' ", con);
       // cmd.CommandText = "Select Group_name from groups where Group_name like '%'+@Name+'%'";
        com.Parameters.AddWithValue("@Name", strName);
        SqlDataAdapter dAdapter = new SqlDataAdapter();
        dAdapter.SelectCommand = com;
        con.Open();
        dAdapter.Fill(objDs);
        con.Close();
        return objDs.Tables[0];</string></string></string></string>
 
Share this answer
 
v2
yes of course u can do this ..
u can also override method names of web service!!!
check out this article
Function Overloading in Web Services[^]
 
Share this answer
 

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