Thursday 8 December 2016

.asp layers, external project access wcf service


presentation -> service -> business -> data

presentation reference -> service
service reference -> business, domain
business reference -> data, domain


run service project -> right click IIS icon -> click service address


click->service.svc


copy web address


open new empty web form solution/project in new visual studio platform(external project)

right click on solution -> add -> service reference


paste address -> go -> select service -> ok

//webform.cs

public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                var proxy = new test_service.InventoryServiceClient(); //call external service

                var suppliers = proxy.GetAll(); //consume service

                GridView1.DataSource = suppliers;

                DataBind();
            }
        }
    }

external service provide gridview









No comments:

Post a Comment