日期:2014-05-18  浏览次数:20865 次

小白跪求个webservice的易懂的例子
从java转到C#,白丁一名,目前的项目要求用webservice,求个webservice速度能懂的例子,最好有注释。
有好的视频教程地址链接也ok!

------解决方案--------------------
这个你绝对看得懂
http://www.cnblogs.com/denylau/archive/2010/07/23/1783530.html
------解决方案--------------------
博客猿里artech写的文章很不错.
http://www.cnblogs.com/artech/
------解决方案--------------------
http://www.cnblogs.com/qidian10/archive/2011/08/05/2128199.html

不管是 ashx 还是 aspx 还是什么 
都只是一个访问的地址和类型而已

最主要的数据的访问协议 交互方式。所以aspx后台的方法怎么写,接口的代码就怎么写
最主要的就是你需要确定你的数据格式 例如是XML? JSON? bytes?
------解决方案--------------------
首先是webservice的代码
------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Configuration;

/// <summary>
///Serviceset 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class Serviceset : System.Web.Services.WebService {

public Serviceset () {

//如果使用设计的组件,请取消注释以下行 
//InitializeComponent(); 
}


[WebMethod]
#region 获取数据库连接
/// <summary>
/// 获取数据库连接
/// </summary>
/// <returns></returns>
public string getdbConnection()
{
return ConfigurationManager.AppSettings["dbConnection"];
}
#endregion
}
---------------------------------
然后是使用的代码
---------------------------------
string serviceurl = "http://" + Properties.Settings.Default.server + ":" + Properties.Settings.Default.port + "/Serviceset.asmx";
Properties.Settings.Default.serverConn = server.InvokeWebService(serviceurl, "getdbConnection",null).ToString();
------解决方案--------------------
给你个 我收藏的。博客园的 有代码和图例
http://www.cnblogs.com/wanghui9072229/archive/2011/03/17/1987371.html