关于网络服务?

时间:2011-05-05 11:14:37

标签: jquery .net ajax

这是我的网络服务....并从jquery ajax请求..但我有一个错误我不知道它是什么?

错误未知的网络方法mobilcevapGetir。参数名称:methodName我猜Everythings还可以,但我不知道..

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

[WebService(Namespace = "http://microsoft.com/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]

 public class mobilSoru
    {

        public int ID { get; set; }
        public string Text { get; set; }
        public List<mobilCevap> Answers = new List<mobilCevap>();

    }

    public class mobilCevap
    {

        public int cvpID { get; set; }
        public int cevapID { get; set; }
        public string Text { get; set; }

    }

    [WebMethod(Description = "Mobile User Registration Service")]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

    public static string mobilcevapGetir()
    {

        var mobilSorular = new List<mobilSoru>();



        SqlConnection cnn = new SqlConnection("server=;database=arabamm;uid=e;pwd=");
        SqlConnection cNnn = new SqlConnection("server=;database=arabamm;uid=;pwd=");

        SqlCommand cmd = new SqlCommand("sorulariGetir", cnn);
        cmd.CommandType = CommandType.StoredProcedure;

        cnn.Open();

        SqlDataReader dr = cmd.ExecuteReader();

        ArrayList sayilar = new ArrayList();
        while (dr.Read())
        {
            sayilar.Add(dr[0]);

            mobilSorular.Add(new mobilSoru { ID = (int)dr[0], Text = (string)dr[1] });

        }


        cnn.Close();



        for (int i = 0; i < sayilar.Count; i++)
        {


            SqlCommand cmDd = new SqlCommand("cevaplariGetir", cNnn);

            cmDd.CommandType = CommandType.StoredProcedure;

            cmDd.Parameters.AddWithValue("@cvpId", mobilSorular[i].ID);

            cNnn.Open();
            SqlDataReader oku = cmDd.ExecuteReader();


            while (oku.Read())
            {
                mobilSorular[i].Answers.Add(new mobilCevap { cvpID = (int)oku[0], cevapID = (int)oku[1], Text = (string)oku[2] });

            }




            cNnn.Close();
        }


        JavaScriptSerializer jSs = new JavaScriptSerializer();


        return jSs.Serialize(mobilSorular);


    }

1 个答案:

答案 0 :(得分:1)

如果在服务方法中放置断点,是否会调用它并成功执行?猜测一切都好可能意味着一切都不好!例如,您似乎没有在连接字符串中指定服务器名称。