asp.net调用webservice

wodelaopos 2012-10-26 10:17:58

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

//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}

[WebMethod(Description = ("被盗账号资料验证"))]
public string CheckUser_Steal(string idindex, string states,string reason)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["database"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("update StealApply set ispass=@states,reason=@reason where idindex=@idindex", con);
cmd.Parameters.Add("states", SqlDbType.VarChar).Value = states;
cmd.Parameters.Add("idindex", SqlDbType.VarChar).Value = idindex;
cmd.Parameters.Add("reason", SqlDbType.VarChar).Value = reason;

try
{
cmd.ExecuteNonQuery();
con.Close();
return "1";
}
catch
{
return "0";
}
}

这个是WebService。在其他页面和代码后置文件中如何调用
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wodelaopos 2012-10-26
  • 打赏
  • 举报
回复
添加完毕,在别的文件里怎么调用呢
wuyq11 2012-10-26
  • 打赏
  • 举报
回复
wuyq11 2012-10-26
  • 打赏
  • 举报
回复
web站点添加web services引用
在config配置地址
也可使用ajax 查询ashx判断
宝_爸 2012-10-26
  • 打赏
  • 举报
回复
在website所在的工程中右键 Add web reference...或者Add service reference...

会生成proxy class. 并且修改web.config.

然后可以可以使用proxy class了。
web.config保存着web service的url.

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧