Aim: Write A Simple Program To Demonstrate WCF Code: Webservice - SVC
Aim: Write A Simple Program To Demonstrate WCF Code: Webservice - SVC
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
Name
Name