Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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;
        }
    }
}
Posted

So build it into the web service, and make the userID/password a parameter in each method call.
 
Share this answer
 
 
Share this answer
 
Comments
arslan3488 19-Oct-10 8:41am    
i cant understand please help me i have to complete this

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