First We have to develop a Duplex communication service then now we have consume that service.so please following steps:
- In a new website add service reference for creating Proxy.
- Design the new form according to requirement sothat we pass inputs as well as outputs from wcf service.
- Add a new class and implement callback interface for Getting or Posting results.
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
///
Summary description for MyClass
/// </summary>
public class MyClass :
CourierTrackNamespace.ICourierTrackCallback
{
public MyClass()
{
}
public static string Info1;
public void Result(string
info)
{
Info1 = info;
}
}
Write following Code in Default.cs
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebControls;
using
System.ServiceModel;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
}
protected void Timer1_Tick(object
sender, EventArgs e)
{
lblres.Text = MyClass.Info1;
}
protected void btnOrder_Click(object
sender, EventArgs e)
{
InstanceContext
ic = new InstanceContext(new MyClass());
CourierTrackNamespace.CourierTrackClient obj = new
CourierTrackNamespace.CourierTrackClient(ic);
obj.PlaceOrder(int.Parse(txtinput.Text));
Timer1.Enabled = true;
}
}
Write following Code in Default.aspx
- Here Some Points to Noted:
No comments:
Post a Comment