0% found this document useful (0 votes)
41 views

Aim: Write A Simple Program To Demonstrate WCF Code: Webservice - SVC

This document contains code for a simple WCF service that demonstrates adding two numbers. It includes code for the service contract interface, service implementation class, and a client test form. The interface defines an Add operation that takes two integer parameters and returns the sum. The implementation class implements this operation by returning the sum of the parameters. The client form allows entering two numbers, selecting the add operation, and displays the result.

Uploaded by

masseffect1111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Aim: Write A Simple Program To Demonstrate WCF Code: Webservice - SVC

This document contains code for a simple WCF service that demonstrates adding two numbers. It includes code for the service contract interface, service implementation class, and a client test form. The interface defines an Add operation that takes two integer parameters and returns the sum. The implementation class implements this operation by returning the sum of the parameters. The client form allows entering two numbers, selecting the add operation, and displays the result.

Uploaded by

masseffect1111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name

Aim: Write a simple Program to demonstrate WCF


Code:
Webservice.svc
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Runtime.Serialization;
System.ServiceModel;
System.Text;

namespace MathWcfService1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to
change the class name "MathService" in code, svc and config file together.
public class MathService : IMathService
{
public int Add(int piNum1, int piNum2)
{
return piNum1 + piNum2;
}
public void DoWork()
{
}
}
}

Math Service.cs
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Runtime.Serialization;
System.ServiceModel;
System.Text;

namespace MathWcfService1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to
change the interface name "IMathService" in both code and config file
together.

Name

[ServiceContract]
public interface IMathService
{
[OperationContract]
// void DoWork();
int Add(int piNum1, int piNum2);
}
}

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 MathServiceTestApp.MathServiceReference;
//using MathServiceTestApp.Properties;
using MathServiceTestApp.ServiceReference1;
namespace MathServiceTestApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MathServiceClient lh = new MathServiceClient();
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
if (comboBox1.Text == "Add")
{

Name

textBox3.Text = lh.Add(a, b).ToString();


}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
OUTPUT:

Name

Aim:-Create A web App For Securing Service using window


Authetication.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<%
Response.Write("Application COde Executed Using :");
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name+"<br>");
Response.Write("is User Autheticated :");
Response.Write(User.Identity.IsAuthenticated.ToString()+"<br>");
Response.Write("Authication type if Autheticated:");
Response.Write(User.Identity.AuthenticationType.ToString()+"<br>");

Response.Write("User Name if Authenticated :");


Response.Write(User.Identity.Name.ToString()+"<br>");
%>
<div>
</div>
</form>
</body>
</html>

Name

You might also like