Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Diagnostics;
Using System.Web;
Using System.Web.Services;
Namespace Webservicedemo
{
<summary>
Summary description of the Service1.
</summary>
[WebService (namespace= "http://www.ezone.com.cn")]
public class EzoneService:System.Web.Services.WebService
{
Public Ezoneservice ()
{
CodeGen: This call is required by the ASP.net Web service designer
InitializeComponent ();
}
Code generated #region Component Designer
Required by the WEB service designer
Private IContainer components = null;
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
}
<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing && components!= null)
{
Components. Dispose ();
}
Base. Dispose (disposing);
}
#endregion
WEB Services Sample
HelloWorld () sample service return string Hello World
To build, uncomment the following lines, and then save and build your project
To test this WEB service, press the F5 key
[WebMethod]
public string HelloWorld ()
{
Return to "Hello World";
}
}
}
File 2////////////////////////////////////////////////////////////////////////
Using System;
Using System.Web.Services;
Using System.Web;
Using ConsoleApp.www.ezone.com.cn;
Namespace ConsoleApp
{
<summary>
Summary description of the CLASS1.
</summary>
Class MyConsole
{
static bool Mystatus=false;
<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main (string[] args)
{
//
TODO: Add code here to start the application
//
Creating a Web Service object
Ezoneservice myserviceobj=new Ezoneservice ();
Console.WriteLine ("Start calling Remote Web Service ...");
Start an asynchronous call to a remote service
Myserviceobj.beginhelloworld (New AsyncCallback (Myhelloworld), myserviceobj);
int i=0;
while (Myconsole.mystatus!=true)
{
i++;
Console.WriteLine ("Wait for the Web service call to end ... #" +i.tostring);
}
Console.WriteLine ("Remote Call End");
}
This method is automatically invoked by the operating system
static void Myhelloworld (IAsyncResult iar)
{
Ezoneservice myservice= (ezoneservice) IAR. asyncstate;
Console.WriteLine (Myservice.endhelloworld (IAR));
End Remote Call
Myconsole.mystatus=true;
}
}
}
Results/////////////////////////////////////////////////////////////////////////
Note: The exact number of waits is related to the speed of your machine, and it has nothing to do with the program!
Start calling Remote Web service ...
Wait for the Web service call to end ... #1
Wait for the Web service call to end ... #2
Wait for the Web service call to end ... #3
Wait for the Web service call to end ... #4
Wait for the Web service call to end ... #5
Wait for the Web service call to end ... #6
Wait for the Web service call to end ... #7
Wait for the Web service call to end ... #8
Wait for the Web service call to end ... #9
Wait for the Web service call to end ... #10
Wait for the Web service call to end ... #11
Wait for the Web service call to end ... #12
Wait for the Web service call to end ... #13
Wait for the Web service call to end ... #14
Wait for the Web service call to end ... #15
Wait for the Web service call to end ... #16
Wait for the Web service call to end ... #17
Wait for the Web service call to end ... #18
Wait for the Web service call to end ... #19
Wait for the Web service call to end ... #20
Wait for the Web service call to end ... #21
Wait for the Web service call to end ... #22
Wait for the Web service call to end ... #23
Wait for the Web service call to end ... #24
Wait for the Web service call to end ... #25
Wait for the Web service call to end ... #26
Wait for the Web service call to end ... #27
Wait for the Web service call to end ... #28
Wait for the Web service call to end ... #29
Wait for the Web service call to end ... #30
Wait for the Web service call to end ... #31
Wait for the Web service call to end ... #32
Wait for the Web service call to end ... #33
Wait for the Web service call to end ... #34
Wait for the Web service call to end ... #35
Wait for the Web service call to end ... #36
Wait for the Web service call to end ... #37
Wait for the Web service call to end ... #38
Wait for the Web service call to end ... #39
Wait for the Web service call to end ... #40
Wait for the Web service call to end ... #41
Wait for the Web service call to end ... #42
Wait for the Web service call to end ... #43
Wait for the Web service call to end ... #44
Wait for the Web service call to end ... #45
Wait for the Web service call to end ... #46
Wait for the Web service call to end ... #47
Wait for the Web service call to end ... #48
Wait for the Web service call to end ... #49
Wait for the Web service call to end ... #50
Wait for the Web service call to end ... #51
Wait for the Web service call to end ... #52
Wait for the Web service call to end ... #53
Wait for the Web service call to end ... #54
Wait for the Web service call to end ... #55
Wait for the Web service call to end ... #56
Wait for the Web service call to end ... #57
Wait for the Web service call to end ... #58
Wait for the Web service call to end ... #59
Wait for the Web service call to end ... #60
Wait for the Web service call to end ... #61
Wait for the Web service call to end ... #62
Wait for the Web service call to end ... #63
Wait for the Web service call to end ... #64
Wait for the Web service call to end ... #65
Wait for the Web service call to end ... #66
Wait for the Web service call to end ... #67
Wait for the Web service call to end ... #68
Wait for the Web service call to end ... #69
Wait for the Web service call to end ... #70
Wait for the Web service call to end ... #71
Wait for the Web service call to end ... #72
Wait for the Web service call to end ... #73
Wait for the Web service call to end ... #74
Wait for the Web service call to end ... #75
Wait for the Web service call to end ... #76
Wait for the Web service call to end ... #77
Wait for the Web service call to end ... #78
Wait for the Web service call to end ... #79
Wait for the Web service call to end ... #80
Wait for the Web service call to end ... #81
Wait for the Web service call to end ... #82
Wait for the Web service call to end ... #83
Wait for the Web service call to end ... #84
Wait for the Web service call to end ... #85
Wait for the Web service call to end ... #86
Wait for the Web service call to end ... #87
Wait for the Web service call to end ... #88
Wait for the Web service call to end ... #89
Wait for the Web service call to end ... #90
Wait for the Web service call to end ... #91
Wait for the Web service call to end ... #92
Wait for the Web service call to end ... #93
Wait for the Web service call to end ... #94
Wait for the Web service call to end ... #95
Wait for the Web service call to end ... #96
Wait for the Web service call to end ... #97
Wait for the Web service call to end ... #98
Wait for the Web service call to end ... #99
Wait for the Web service call to end ... #100
Wait for the Web service call to end ... #101
Wait for the Web service call to end ... #102
Wait for the Web service call to end ... #103
Wait for the Web service call to end ... #104
Wait for the Web service call to end ... #105
Wait for the Web service call to end ... #106
Wait for the Web service call to end ... #107
Wait for the Web service call to end ... #108
Wait for the Web service call to end ... #109
Wait for the Web service call to end ... #110
Wait for the Web service call to end ... #111
Wait for the Web service call to end ... #112
Wait for the Web service call to end ... #113
Wait for the Web service call to end ... #114
Wait for the Web service call to end ... #115
Wait for the Web service call to end ... #116
Wait for the Web service call to end ... #117
Wait for the Web service call to end ... #118
Wait for the Web service call to end ... #119
Wait for the Web service call to end ... #120
Wait for the Web service call to end ... #121
Wait for the Web service call to end ... #122
Wait for the Web service call to end ... #123
Wait for the Web service call to end ... #124
Wait for the Web service call to end ... #125
Wait for the Web service call to end ... #126
Wait for the Web service call to end ... #127
Wait for the Web service call to end ... #128
Wait for the Web service call to end ... #129
Wait for the Web service call to end ... #130
Wait for the Web service call to end ... #131
Wait for the Web service call to end ... #132
Wait for the Web service call to end ... #133
Wait for the Web service call to end ... #134
Wait for the Web service call to end ... #135
Wait for the Web service call to end ... #136
Wait for the Web service call to end ... #137
Wait for the Web service call to end ... #138
Wait for the Web service call to end ... #139
Wait for the Web service call to end ... #140
Wait for the Web service call to end ... #141
Hello World
Remote Call End
Press any key to continue
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.