科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道应用软件How to write XML Web Service

How to write XML Web Service

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

一步一步教你如何写web service,如何调用web service函数。转载请务必注明作者,出处

作者:lirincy 来源:CSDN 2008年3月29日

关键字: Service web XML Web开发 软件

  • 评论
  • 分享微博
  • 分享邮件

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?

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章