-
using?System;
-
using?System.Collections.Generic;
-
using?System.ComponentModel;
-
using?System.Data;
-
using?System.Drawing;
-
using?System.Linq;
-
using?System.Text;
-
using?System.Windows.Forms;
-
namespace?WindowsFormsApplication1
- {
-
??????public?partial?class?Form1?:?Form
- ??????{
-
??????????public?Form1()
- ??????????{
- ??????????????InitializeComponent();
- ??????????}
-
??????????private?void?button1_Click(object?sender,?EventArgs?e)
- ??????????{
-
??????????????localhost.Service?t?=?new?WindowsFormsApplication1.localhost.Service();
- ??????????????MessageBox.Show(t.HelloWorld());
-
??????????????MessageBox.Show("Down!");
- ??????????}
-
??????????private?void?button2_Click(object?sender,?EventArgs?e)
- ??????????{
-
??????????????localhost.Service?t?=?new?WindowsFormsApplication1.localhost.Service();
-
??????????????t.HelloWorldCompleted?+=?new?WindowsFormsApplication1.localhost.HelloWorldCompletedEventHandler(t_HellowordCompleted);
- ??????????????t.HelloWorldAsync();
-
??????????????MessageBox.Show("Down!");
- ??????????}
-
??????????private?void?t_HellowordCompleted(object?sender,?localhost.HelloWorldCompletedEventArgs?e)
- ??????????{
- ??????????????MessageBox.Show(e.Result.ToString());
- ??????????}
-
??????????private?void?button3_Click(object?sender,?EventArgs?e)
- ??????????{
-
??????????????MessageBox.Show((new?localhost.Service()).GetTime());
- ??????????}
- ??????}
- }
- ---------------------webService----------------------------
-
using?System;
-
using?System.Linq;
-
using?System.Web;
-
using?System.Web.Services;
-
using?System.Web.Services.Protocols;
-
using?System.Xml.Linq;
-
using?System.Threading;
-
[WebService(Namespace?=?"http://tempuri.org/")]
- [WebServiceBinding(ConformsTo?=?WsiProfiles.BasicProfile1_1)]
-
-
-
public?class?Service?:?System.Web.Services.WebService
- {
-
?????public?Service?()?{
-
?????????
-
?????????
- ?????}
- ?????[WebMethod]
-
?????public?string?HelloWorld()?{
- ?????????Thread.Sleep(3000);
-
?????????return?"Hello?World";
- ?????}
-
????
-
?????[WebMethod(false,System.EnterpriseServices.TransactionOption.NotSupported,10)]
-
?????public?string?GetTime()
- ?????{
-
?????????return?DateTime.Now.ToString();
- ?????}
- ????
- }
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|