当前位置:编程学习 > C#/ASP.NET >>

C# web service sample and trouble shooting

I   wrote   the   hello   world   web   service   in   C#   by   Visual   Studio, 
however,   I   hit   several   trouble,   finally   I   resolved   them   by   2   hours. 

To build a web service is easy, the web service looks like this:

then here is how to use the web service by visual studio.

In visual studio,
first you need go to solution window ---> web reference , right click on it, ---> add web reference

A dialog window pops up, you need input "http://shiny:89/Service1.asmx" hit go button
web reference name is any name you decided.
shiny equals localhost, shiny is my computer name.



In your source code, how to refer this web service, see below in red,
addsvc is web reference name,
Service1 is real service name,
do not confuse the two guys.




Service1 is same as in browser,







protected void runSrvice_Click(Object sender, EventArgs e)
        {

            addsvc.Service1 mySvc = new addsvc.Service1();
            Label1.Text = mySvc.HelloWorld();
            Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),
                          Int32.Parse(txtNum2.Text)).ToString();
        }

--------------------编程问答-------------------- 不明LZ在说什么 --------------------编程问答-------------------- 支持搂主,收藏
补充:.NET技术 ,  Web Services
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,