Hellow,
У меня есть веб-сервис, чтобы показать простой запрос. веб-сервис вернулся ни с чем. что я имею в виду, это возвращает ни с чем, что я не могу найти кнопку вызова. Вместо этого я получаю сообщение об ошибке.
мой файл ASMX похож на следующий.
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Script.Serialization;
using System.Web.Services;
namespace El_Alamia.GetData
{
[WebService(Namespace = "http://microsoft.com/webservices/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//[WebService(Namespace = "http://tempuri.org/")]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class GetJsonData : System.Web.Services.WebService
{
[WebMethod]
public void GetHomeData()
{
string cs = ConfigurationManager.ConnectionStrings["AlaamiaConnectionString"].ConnectionString;
List<HomePage> HomeList = new List<HomePage>();
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("spGetData", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
HomePage PageFormat = new HomePage();
PageFormat.TextPath = rdr["Text_Path"].ToString();
PageFormat.PicPath = rdr["Pic_Path"].ToString();
HomeList.Add(PageFormat);
}
}
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(HomeList));
}
public class HomePage
{
public string TextPath { get; set; }
public string PicPath { get; set; }
}
}
}
Сообщение об ошибке
This web service is using http://tempuri.org/ as its default namespace.
Recommendation: Change the default namespace before the XML Web service is made public.
Each XML Web service needs a unique namespace in order for client applications to distinguish it from other services on the Web. http://tempuri.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace.
Your XML Web service should be identified by a namespace that you control. For example, you can use your company's Internet domain name as part of the namespace. Although many XML Web service namespaces look like URLs, they need not point to actual resources on the Web. (XML Web service namespaces are URIs.)
For XML Web services creating using ASP.NET, the default namespace can be changed using the WebService attribute's Namespace property. The WebService attribute is an attribute applied to the class that contains the XML Web service methods. Below is a code example that sets the namespace to "http://microsoft.com/webservices/":
C#
[WebService(Namespace="http://microsoft.com/webservices/")]
public class MyWebService {
// implementation
}
и также просто чтобы быть уведомленным, мой web.config имеет это
<webServices>
<conformanceWarnings>
<remove name='BasicProfile1_1'/>
</conformanceWarnings>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>