SIGN UP MEMBER LOGIN:    
ARTICLE

Authenticate Web Service Client - An ASP.NET Web Application

Posted by Shripad Kulkarni Articles | Web Services in C# March 04, 2002
This client application shows you how to access Authenticate Web service from an ASP.NET Web application.
Reader Level:

This client application shows you how to access Authenticate Web service.

Create a project of the type ASP.NET Web.



Design your web page



Generate the proxy code that exposes the public methods from the WebService.

The following command can be used to do so....

wsdl /namespace:AuthNameSpace http://localhost/AuthenticateService/Service1.asmx?wsdl

The wsdl.exe command assigns a new namespace for the Service.asmx available on the server.

It creates a C# ( Service1.cs ) file that contains the proxy code to access the public mentods exposed by the remote web server.

Compile this c# file using the csc exe command. Compile the C# program into a DLL that will be used by the ASP application. The application locates the DLL sitting in the bin directory and loads the library automatically.

csc /t:library /r:System.Web.Services.Dll /out:bin/Authenticate.dll Service1.cs

Right Click the Add Reference item in Solution Explorer.



Select the System.Web.WebServices.DLL option from the NET tab & Select the Authenticate.DLL from the Projects tab. ( Select the dll residing in bin directory ).

In your C# source , Include the namespace AuthNameSpace.

using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using AuthNameSpace ;
using System.IO ;
using System.Xml;
namespace AuthenticateASP
{
///
/// Summary description for WebForm1.
///
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
//Create a method for the button click event.

private void Button1_Click(object sender, System.EventArgs e)
{
TextBox3.Text = "" ;
TextBox4.Text = "" ;
TextBox5.Text = "" ;
TextBox6.Text = "" ;
TextBox7.Text = "" ;
Service1 svc1 =
new Service1() ;
XmlTextReader reader =
null;
string obj = svc1.GetUserInfo(TextBox2.Text , TextBox1.Text);
if ( obj == "" )
{
// MessageBox.Show("UserName / Password not found in database" , "Authentication Failed" ,
//MessageBoxButtons.OK , MessageBoxIcon.Error);;
return ;
}

Call the GetUserInfo method that takes in the 2 parameters and returns data in  XML format.
Parse the XML data and display it in your web page. Is that simple

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Become a Sponsor