private void btnketnoi_Click(object sender, EventArgs e) { try { if (cbbkieukn.SelectedIndex == 0) { EndpointAddress address = new EndpointAddress(new Uri("http://localhost:8888/BasicHttpBinding/Test1")); ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new BasicHttpBinding(), address); service = factory.CreateChannel(); rtxtthongtin.Text = service.GetAuthors(); } if (cbbkieukn.SelectedIndex == 1) { EndpointAddress address = new EndpointAddress(new Uri("http://localhost:8888/WSHttpBinding/Test2")); ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new WSHttpBinding(), address); service = factory.CreateChannel(); rtxtthongtin.Text = service.GetAuthors(); } if (cbbkieukn.SelectedIndex == 2) { EndpointAddress address = new EndpointAddress(new Uri("net.tcp://localhost:8888/NetTcpBinding/Test3")); ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new NetTcpBinding(), address); service = factory.CreateChannel(); rtxtthongtin.Text = service.GetAuthors(); } } catch (Exception ex) { MessageBox.Show("Không kết nối được!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); rtxtthongtin.Text = ""; } }
public RootClass(IService1 service1, IService2 service2, string stringProperty, int intProperty) { this.service1 = service1; this.service2 = service2; StringProperty = stringProperty; IntProperty = intProperty; }
/// <summary> /// Constructor - takes in implementation of IService1 /// </summary> /// <param name="service">The IService1 implementation</param> public Service1(IService1 service) { if (service == null) throw new ArgumentNullException(nameof(service)); this._service = service; }
private void btnngatkn_Click(object sender, EventArgs e) { service = null; txttinhtrang.Text = "Ngắt kết nối!"; grbkieukn.Enabled = true; btnketnoi.Enabled = true; btnngatkn.Enabled = false; }
public Form1() { InitializeComponent(); serv = new Service1Client(); string[] cus = serv.readTable("Customer"); listBox1.Items.Clear(); foreach (string c in cus) listBox1.Items.Add(c); }
public MainForm() { InitializeComponent(); InstanceContext m_CallBackContext; m_CallBackContext = new InstanceContext(this); DuplexChannelFactory<IService1> m_ChannelFactory; NetTcpBinding binding = new NetTcpBinding(); Uri baseAddress = new Uri("net.tcp://localhost:10086/WCFHostServer/Service1"); m_ChannelFactory = new DuplexChannelFactory<IService1>(m_CallBackContext, binding, new EndpointAddress(baseAddress)); m_Innerclient = m_ChannelFactory.CreateChannel(); }
public Form2(IService1 serv, string cid) { InitializeComponent(); this.serv = serv; this.cid = cid; string[] prd = serv.readTable("Product"); listBox1.Items.Clear(); foreach (string p in prd) listBox1.Items.Add(p); mesg= new Queue<string>(); mesg.Enqueue(listBox1.Items[0].ToString() + "\t Quantity"); }
protected void Page_Load(object sender, EventArgs e) { address = new EndpointAddress("http://localhost:6000/service"); binding = new WSHttpBinding(); factory = new ChannelFactory <IService1>(binding, address); proxy = factory.CreateChannel(); DataTable ntable = new DataTable(); ntable.Columns.Add("ID"); ntable.Columns.Add("NodeID"); ntable.Columns["ID"].AutoIncrement = true; ntable.Columns["ID"].AutoIncrementSeed = 1; ntable.Columns["ID"].AutoIncrementStep = 1; DataColumn[] nkeys = new DataColumn[1]; nkeys[0] = ntable.Columns["ID"]; ntable.PrimaryKey = nkeys; ViewState["NTable"] = ntable; }
private void btnketnoi_Click(object sender, EventArgs e) { try { if (rdbasic.Checked == true) { address = new EndpointAddress(new Uri("http://localhost:8888/BasicHttpBinding")); factory = new ChannelFactory<IService1>(new System.ServiceModel.BasicHttpBinding(), address); service = factory.CreateChannel(); checkConnect = service.checkServer(); } else if (rdws.Checked == true) { address = new EndpointAddress(new Uri("http://localhost:8888/WSHttpBinding")); factory = new ChannelFactory<IService1>(new WSHttpBinding(), address); service = factory.CreateChannel(); checkConnect = service.checkServer(); } else if (rdnet.Checked == true) { address = new EndpointAddress(new Uri("net.tcp://localhost:8888/NetTcpBinding")); factory = new ChannelFactory<IService1>(new NetTcpBinding(), address); service = factory.CreateChannel(); checkConnect = service.checkServer(); } if(checkConnect = service.checkServer()) { txttinhtrang.Text = "Đã kết nối với Server!"; btnngatkn.Focus(); grbkieukn.Enabled = false; btnketnoi.Enabled = false; btnngatkn.Enabled = true; } } catch (Exception ex) { txttinhtrang.Text = "Lỗi kết nối!"; } }
public static void Test() { string baseAddress = "http://" + Environment.MachineName + ":8000/Service"; ServiceHost host = new ServiceHost(typeof(Service1), new Uri(baseAddress)); host.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), ""); host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true }); host.Open(); Console.WriteLine("Host opened"); ChannelFactory <IService1> factory = new ChannelFactory <IService1>(new BasicHttpBinding(), new EndpointAddress(baseAddress)); IService1 proxy = factory.CreateChannel(); Console.WriteLine(proxy.GetData(new MyRequest { name = "hello" })); ((IClientChannel)proxy).Close(); factory.Close(); Console.Write("Press ENTER to close the host"); Console.ReadLine(); host.Close(); }
protected void Button1_Click(object sender, EventArgs e) { try { if (Page.IsValid) { wfc.NewRec(Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(DropDownList2.SelectedValue), Convert.ToInt32(TextBox1.Text), Convert.ToDateTime(DateO.Text)); ChannelFactory <IService1> factory = new ChannelFactory <IService1>(binding, endpoint); IService1 channel = factory.CreateChannel(); channel.CountOfDBRows((GridView1.Rows.Count + 1).ToString()); factory.Close(); GridView1.DataSource = wfc.GetData(); GridView1.DataBind(); } } catch (Exception exc) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Host closed!')", true); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "") { endPointAddr = "net.tcp://" + textBox2.Text + ":8000/MyService"; NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress endpointAddress = new EndpointAddress(endPointAddr); Append("Attempt to connect to: " + endPointAddr); IService1 proxy = ChannelFactory <IService1> .CreateChannel(tcpBinding, endpointAddress); using (proxy as IDisposable) { Append("Message from server: " + (proxy.HelloWorld(textBox1.Text) + " back to you :)")); } } }
/// <summary> /// Entry point /// </summary> /// <param name="args">Head node to contact</param> public static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage:"); Console.WriteLine("\tClusterWebHttp.exe <headNode>"); Console.WriteLine("Example:"); Console.WriteLine("\tClusterWebHttp.exe myHeadNode"); return; } string headNode = args[0]; string service = "WebHttpDemo"; SessionStartInfo ssi = new SessionStartInfo(headNode, service); ssi.SessionResourceUnitType = SessionUnitType.Core; ssi.MaximumUnits = 1; ssi.MinimumUnits = 1; ssi.Secure = false; Session session = Session.CreateSession(ssi); ChannelFactory <IService1> factory = new ChannelFactory <IService1>(new WebHttpBinding(WebHttpSecurityMode.None), session.EndpointReference); factory.Endpoint.Behaviors.Add(new WebHttpBehavior()); IService1 proxy = factory.CreateChannel(); for (int i = 0; i < 5; ++i) { Console.WriteLine(proxy.Echo("hello" + i)); } ((IClientChannel)proxy).Close(); factory.Close(); session.Close(); }
static void GetToDoListByName(string Name) { using (ChannelFactory <IService1> cf = new ChannelFactory <IService1>(new WebHttpBinding(), "http://localhost:8000/Index")) { cf.Endpoint.Behaviors.Add(new WebHttpBehavior()); IService1 channel = cf.CreateChannel(); List <ToDo> GTodoByID = new List <ToDo>(); Console.WriteLine("Vems Todos Vill du se "); String TName = Console.ReadLine(); GTodoByID = channel.GetToDoListByName(TName); foreach (var g in GTodoByID) { Console.WriteLine(g.Id); Console.WriteLine(g.Description); Console.WriteLine(g.Name); Console.WriteLine(g.DeadLine); Console.WriteLine(g.EstimationTime); } Console.ReadLine(); } }
/* The client that sits on the field where watson is located */ public string StartClient(string ipAddress, int port) { try { string endPointAddr = ""; endPointAddr = "net.tcp://" + ipAddress + ":" + port + "/MyService"; NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; //tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; //tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress endpointAddress = new EndpointAddress(endPointAddr); m_proxy = ChannelFactory <IService1> .CreateChannel(tcpBinding, endpointAddress); string res = m_proxy.HelloWorld("test"); return(res); } catch (Exception err) { return(err.Message); } }
/* The client that sits on the field where watson is located */ public string StartClient(string ipAddress, int port) { try { NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.OpenTimeout = TimeSpan.FromSeconds(15); tcpBinding.ReceiveTimeout = TimeSpan.FromSeconds(10); tcpBinding.SendTimeout = TimeSpan.FromSeconds(10); tcpBinding.CloseTimeout = TimeSpan.FromSeconds(10); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Mode = SecurityMode.Transport; string endPointAddr = ""; endPointAddr = "net.tcp://" + ipAddress + ":" + port + "/MyService"; pipeFactory = new DuplexChannelFactory <IService1>( new InstanceContext(this), tcpBinding, new EndpointAddress(endPointAddr)); m_proxy = pipeFactory.CreateChannel(); string res = m_proxy.HelloWorld("test"); return(res); } catch (Exception err) { return(err.Message); } }
public WithDefaultAndSingleParameter(IService1 service1) { }
public With3Parameters(IService1 service1, IService2 service2) { }
public H(IService1 s1) { _s1 = s1; }
private void button1_Click(object sender, EventArgs e) { var productAddress = new EndpointAddress("net.tcp://localhost:9010/ProductService"); _productChannel = ChannelFactory<IService1>.CreateChannel(new NetTcpBinding(), productAddress); }
public Database(IService1 one, IService2 two) { }
public ExampleTwoWithSeparateArgument2(IService1 s1) { _s1 = s1; }
public ServerStatusRepository(IService1 service) { _webservice = service; }
internal WithServiceInternal(IService1 service) { Service = service; }
public RootClass(IService1 service1, IService2 service2) : this(service1, service2, "DEFAULT", 1976) { }
public Service3DependsOnService1And2(IService1 s1, IService2 s2) { }
public SharedParamFixtureTest(IService service, IService1 service1, [Column(123, 456)] int parameter) { this.service = service; this.service1 = service1; this.parameter = parameter; }
public ExampleTwoWithOneArgument(IService1 s1) { _s1 = s1; }
private ExampleTwoArgumentsPrivate(IService1 s1, IService2 s2) { _s1 = s1; _s2 = s2; }
public ExampleTwoArguments(IService1 s1, IService2 s2) { _s1 = s1; _s2 = s2; }
public Runner(IService1 service1, IService2 service2, IConfig config, IControl control) { }
public HomeController(IService1 service) { _Service1 = service; }
public DefaultService2(IService1 service1) { this.service1 = service1; }
private void button1_Click(object sender, EventArgs e) { Ouvrage ouvrage = new Ouvrage(); if (vide.Checked) { ouvrage.Type = null; } if (livre.Checked) { ouvrage.Type = "livre"; } if (these.Checked) { ouvrage.Type = "these"; } if (memoire.Checked) { ouvrage.Type = "memoire"; } if (titre.Text == "") { ouvrage.Titre = null; } else { ouvrage.Titre = titre.Text; } if (theme.Text == "") { ouvrage.Theme = null; } else { ouvrage.Theme = theme.Text; } if (auteur.Text == "") { ouvrage.Auteur = null; } else { ouvrage.Auteur = auteur.Text; } ChannelFactory <IService1> channelFactory = new ChannelFactory <IService1>("BasicHttpBinding_IService1"); IService1 operation = channelFactory.CreateChannel(); var bindingList = new BindingList <Ouvrage>(operation.Recherche(ouvrage)); Console.WriteLine(operation.Recherche(ouvrage).Count); var source = new BindingSource(bindingList, null); dataGridView1.Rows.Clear(); dataGridView1.DataSource = source; }
public Service3DependsOnService1(IService1 s1) { }
public MyService(IService1 service1, IService2 service2, IOptions <MyServiceOptions> serviceOptions) { var connectionString = serviceOptions.Value.ConnectionString; //... }
private void btnngat_Click(object sender, EventArgs e) { service = null; MessageBox.Show("Đã ngắt kết nối tới máy chủ...","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information); rtxtthongtin.Text = ""; }
public Controller(IService1 s1, IService2 s2, IService3 s3) { this.S1 = s1; this.S2 = s2; this.S3 = s3; }
public Service3(IService1 service1, IService2 service2) { Service1 = service1; Service2 = service2; }
#pragma warning disable CA1801 //Parameter is never used. Remove the parameter or use it in the method body public With3Parameters(IService1 service1) { }
public MyFunction1(IService1 service1, ILogger logger) { this.service1 = service1; this.logger = logger; logger.LogWarning($"Creating {this}"); }
public Service3(IService1 service1, IService2 service2) { _service1 = service1; _service2 = service2; }
public WithPrivateConstructor(IService1 service1) { }
public ExampleOneArgument(IService1 s1) { _s1 = s1; }
public Service3(IService1 svc) { Service1 = svc; }
private WithPrivateConstructor(IService1 service1, IService2 service2) { }
public Function1(IService1 service1, ILogger logger) { _service1 = service1; _logger = logger; _logger.LogWarning($"Creating {this}"); }
public ServiceRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3) { }
public With3Parameters(IService1 service1) { }
public MultipleDiAnnotatedManager(IService1 service1) { Service1 = service1; }
public TargetService(IService1 svc1, Lazy <IService2> svc2) { _svc1 = svc1; _svc2 = svc2; }
public ExampleTwoWithSeparateArgument2(IService1 s1, IService2 s2) { _s1 = s1; _s2 = s2; }