How to write XML Web Service

How to write XML Web Service

{By 林刚 lirincy@163.com}

 

1.       install IIS, IIS can be installed from Add/Remove Program from Control Panel and select Windows Component install.

2.       install Microsoft Visual Studio 2003. this will install .NET Framework 1.1.

3.       install asp.NET: cd /WINDOWS/Microsoft.NET/Framework/v1.1.4322 and execute aspnet_regiis.exe /i;

4.       in VS.NET, new an ASP.net web service project like this:

  

5.       after the project is created, the project is look like this:

Right click the Service1.asmx and select view code, add the follow code into the Service1 class source.

This will expose four functions into public which can do calculation for client.

6.       right click the project and select build, any suggestion and comments please contact 林刚 lirincy@163.com.

7.       run the solution, before run the solution, you need to enable windows integrated authentication for this web site, like following:

Click edit and make sure the windows authentication is checked.

After these steps, run the solution and you will see web page like this:

8.       you can also get this page by browse the asmx file in local web site:

9.       Let’s then create a program to consume the web service, add a new Windows project to current solution, named WebServiceClient.

10.   right click Reference in the new project and select add Web Reference, input the url you get from the running result of the web service project, you will get:

Select add reference.

Then the project will look like this:

 

11.   right click the Form1.cs file in project and select view code, add following reference creation statement into Form1 class:

private WebServiceClient.WebServiceRef.Service1 Calc = new WebServiceClient.WebServiceRef.Service1();

 

add following code into Form1 class to call the webservice function:

 

12.   right click WebServiceClient project and select Debug/new instance. You will get the UI of result and you can test it, following is a sample of addition operation. the result seems incorrect, , tell me why?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值