Web Service Software Factory - BlueYonderAirLines tutorial contined....

The Web Service Software Factory was my introduction to WCF and DSL's and I must say I was very VERY impressed.   The Web Service Software factory will be my tool of choice when working with WCF.   As great as the Tutorial was it assumed a wee bit to much knowledge on my part and ended somewhat abruptly - without and idea of how to use the many projects and classes that were generated for me.   For those like myself new to WCF the following is a continuation that will let you use the demo you created :)

New to WCF/WSSF?  Visit http://code.msdn.microsoft.com/ServiceFactory 

  • Topics Covered
    • Hands-on Lab continued - how to consume a WCF service (with and without Config file)
    • Assumptions that had me googling and burning hours...
    • Configure IIS for WCF

BYA.Mfg.SCM.Svc.WCF :: Tests :: BYA.Mfg.SCM.Svc.WCF.Client :: MainForm.cs 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

using BYA.Mfg.SCM.Svc.WCF.Client.MaterialMgmtProxy;

namespace BYA.Mfg.SCM.Svc.WCF.Client
{
    public partial class MainForm : Form
    {
        PartsMgmtServiceContractClient client;

            public MainForm()
        {
            InitializeComponent();
            client = new PartsMgmtServiceContractClient("DefaultEndpoint");
        }

        // Utilizes App.Config
        private void ExecuteButton_Click(object sender, EventArgs e)
        {
            // Configure the request utilizing input - valid input
            // are "one" and "two" - all others will return 0 values
            DemandRequest request = new DemandRequest();
            request.AircraftPart = new AircraftPart();
            request.AircraftPart.Part = SearchText.Text;

            ResultsGrid grid = new ResultsGrid(client.GetRequirementDemand(request));
            grid.Show();
        }

-- OR --

        // Utilizes Channel
        private void ExecuteButton_Click(object sender, EventArgs e)
        {
            // Configure the request utilizing input - valid input
            // are "one" and "two" - all others will return 0 values
            DemandRequest request = new DemandRequest();
            request.AircraftPart = new AircraftPart();
            request.AircraftPart.Part = SearchText.Text;

            BasicHttpBinding binding = new BasicHttpBinding();
            EndpointAddress endPoint = new EndpointAddress("http://localhost:2035/BYA.Mfg.SCM.Svc.WCF.Host/MaterialMgmt.svc");

            ChannelFactory<PartsMgmtServiceContract> channelFactory =
                new ChannelFactory<PartsMgmtServiceContract>(binding, endPoint);

            PartsMgmtServiceContract service = channelFactory.CreateChannel();

            DemandResponse response = service.GetRequirementDemand(new DemandRequest1(request));

            ResultsGrid grid = new ResultsGrid(response.PartLevel);
            grid.Show();

        }
    }
}

Be sure to read this blog on WCF Proxy Wrapper - it holds important information disposing!


Tags: , ,
Categories:


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know