WebServices simple example

xiaoxiao2021-03-06  64

1. Writing HelloWorld.asmx <% @ WebService Language = "C #" class = "HelloWorld"%>

Using system.web.services;

[WebService (Namespace = "http://gloryview.com/webservices")] Public class helloworld: WebService {[WebMethod] public string SayHelloWorld () {Return "Hello World!";}}

2. Call the command line, type: disco / o: test http://192.168.1.96/aspx/helloWorld.asmx/o: Test is stored in the test directory, default is the current directory

3. C: / inetpub / wwwroot / aspx / test> WSDL.EXE / L: CS / N: TestServices /out:HelloWorld.cs helloworld.wsdl / n: WebServices name space, the namespace introduced to the ASPX client call / OUT : Output CS file, then compile into a DLL, call the client

4. CSC / T: library helloWorld.cs compiles to HelloWorld.dll, stored in bin directory.

5. Write TEST.ASPX <% @ page language = "c #"%> <% @ Import namespace = "YYTEST"%>