private void btnConnection_Click(object sender, EventArgs e) { asynchronousClient = new AsynchronousSocketClient(AsynchronousData); synchroClient.Connect(ServiceIP, 7777); asynchronousClient.Connect(ServiceIP, 7777); HelloWCF.Connection(); HelloAsyWCF.Connection(); btnStart.Enabled = true; btnSendMess.Enabled = true; }
public void Run() { Uri remoteEp = new Uri("http://localhost:8084/ServiceHelloWCF.svc"); WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(remoteEp)); ProtocolVersion ver = new ProtocolVersion11(); // To enable WSDiscoveryApril2005 and Soap12WSAddressingAugust2004 //ProtocolVersion ver = new ProtocolVersion10(); /// ProtocolVersion11 can be used if the corresponding WCF desktop server application /// WcfServer uses wsHttpBinding instead of the custom binding "Soap11AddressingBinding" m_clientProxy = new ServiceHelloWCFClientProxy(binding, ver); m_clientProxy.IgnoreRequestFromThisIP = false; if (!Discover(m_clientProxy)) { Debug.Print("Discovery failed, trying direct address"); } HelloWCF req = new HelloWCF(); req.name = "World"; try { HelloWCFResponse resp = m_clientProxy.HelloWCF(req); Debug.Print("\n\n*****************"); Debug.Print(resp.HelloWCFResult); Debug.Print("*****************\n\n"); } catch (WsFaultException ex) { Debug.Print("DPWS Fault: " + ex.Message); } finally { m_clientProxy.Dispose(); } }
private void btnStart_Click(object sender, EventArgs e) { Thread downFile = new Thread((ThreadStart) delegate() { asynchronousClient.DownFile(txtServerFileName.Text); }); Thread th = new Thread((ThreadStart) delegate() { DownFile("WCF同步" + txtServerFileName.Text, txtServerFileName.Text); }); string cmd = "GetFile " + txtServerFileName.Text; byte[] byt = Encoding.ASCII.GetBytes(cmd); synchroClient.SendMess(byt); downFile.Start(); HelloWCF.BeginDownFile(txtServerFileName.Text, null, null); th.Start(); }
public void Run() { Uri remoteEp = new Uri("http://localhost:8001/ServiceHelloWCF"); WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(remoteEp)); /// ProtocolVersion11 can be used if the corresponding WCF desktop server application /// WcfServer uses wsHttpBinding instead of the custom binding "Soap11AddressingBinding" m_clientProxy = new ServiceHelloWCFClientProxy(binding, new ProtocolVersion11()); m_clientProxy.IgnoreRequestFromThisIP = false; if (!Discover(m_clientProxy)) { Debug.Print("Discovery failed, trying direct address"); m_clientProxy.EndpointAddress = "http://localhost:8084/319D0A4D-2253-47DC-AC4A-C1951FF6667D"; } HelloWCF req = new HelloWCF(); req.name = "World"; try { HelloWCFResponse resp = m_clientProxy.HelloWCF(req); Debug.Print("\n\n*****************"); Debug.Print(resp.HelloWCFResult); Debug.Print("*****************\n\n"); } catch (WsFaultException ex) { Debug.Print("DPWS Fault: " + ex.Message); } m_clientProxy.Dispose(); }
private void btnSendMess_Click(object sender, EventArgs e) { synchroClient.SendMess("消息抓包测试"); HelloWCF.SayHello("消息抓包测试"); }