手把手教你学Web Service

http://tech.ddvip.com   2007年09月01日    社区交流

内容摘要:既然Web Service这么好,怎样写阿?在下就将在Visual Studio.net 中究竟如何编写Web Service的全过程一一奉上。

  To test, click the ’Invoke’ button.

  按了之后,就出现:

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">Hello World</string>

  OK!我们的第一个Web Service 成功了!

  2.让我们试一下改改一些东西,输入参数好像太简单了,加点东西吧:

  public string HelloWorld(string strInput)

  返回值变为return str+"Hello World"

  其余不变,有什么事情发生那?执行之,第一个界面不变,但是有invoke按钮的那个页面就不同了,多了一个表格,parameter那一列多了个strInput:,value那列多了一个text box。喔,原来是在text box里面输入strInput的值。随便打什么,比方说"Nfs is the best",按invoke按钮,返回如下信息:

<?xml version="1.0" encoding="utf-8" ?>
   <string xmlns="http://tempuri.org/">Nfs is the best Hello World</string>

  会用了吗?

  3.在变化一些,输入参数变为数组

public string HelloWorld(string[] str)
{
   return str[0]+"Hello World";
}

  执行之,第一个页面好像没什么问题,但是一点hello world这个链接,就好像出错了!

Test Test forms are only available for methods with non-array primitive types as parameters.
SOAP
The following is a sample SOAP request and response. The placeholders shown need to be replaced with actual values.
.............

作者:nfs    责编:豆豆技术应用

正在加载评论...