Web服务的网络认证 [英] Network authentication of a webservice
本文介绍了Web服务的网络认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了很多关于Web服务上的网络身份验证的解决方案,但是找不到任何帮助,基本上我想对Web服务进行身份验证,以便当有人使用它时,它需要用户名并通过
Form1.cs
hi , i tried alot to find a solution regarding network authentication on webservice but cant find any help , basically i want to authenticate a webservice that when some body use it , it require username and pass
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZTestFormApp.DataAccessService;
namespace ZTestFormApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
int x = int.Parse(txtX.Text);
int y = int.Parse(txtY.Text);
int result = 0;
DataAccessService.DataAccessServiceSoapClient c = new DataAccessServiceSoapClient();
result = c.Add(x, y);
txtResult.Text = result.ToString();
}
}
}
DataAccessService.asmx.cs
DataAccessService.asmx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace ZTestWebService
{
/// <summary>
/// Summary description for DataAccessService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class DataAccessService : System.Web.Services.WebService
{
[WebMethod]
public int Add(int x, int y)
{
return x+y;
}
}
}
推荐答案
因此将其构建到Web服务中,并在每个方法调用中将userID/password作为参数.
So build it into the web service, and make the userID/password a parameter in each method call.
您可以检查一下.
http://progtutorials.tripod.com/Authen.htm [
You can check this.
http://progtutorials.tripod.com/Authen.htm[^]
这篇关于Web服务的网络认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文