0
大家好下面是我想使用的一個WebService類(我寫它)。問題是我不太清楚如何去使用它。我有一個WinForm,通過DataAccessObject
的另一個實例連接到數據庫。如何去使用Web服務
用戶必須能夠點擊一個按鈕,該按鈕將打開表單的網站版本並從那裏修改數據庫。
問題是我不知道如何使用這項服務,這樣做
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml.Linq;
using System.Configuration;
/// <summary>
/// Summary description for DataManager
/// </summary>
[WebService(Namespace = "/201103578Site//Default.aspx")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
//[System.Web.Script.Services.ScriptService]
public class DataManager : System.Web.Services.WebService
{
XElement[] xmlCompany = null;
XElement[] xmlCandidate = null;
XElement[] xmlQualification = null;
public DataManager()
{
//Uncomment the following line if using designed components
//InitializeComponent();
DataAccessObject.DataAccessObject daoDataBase = new DataAccessObject.DataAccessObject(ConfigurationManager.ConnectionStrings[1].ToString());
daoDataBase.openConnection();
xmlCompany = daoDataBase.sqlSelectCompany(new SQL.SqlImplementation(), "Select * From Company");
xmlCandidate = daoDataBase.sqlSelectCandidate(new SQL.SqlImplementation(), "Select * From Candidate");
xmlQualification = daoDataBase.sqlSelectQualification(new SQL.SqlImplementation(), "Select * From Qualification");
daoDataBase.closeConnection();
}
[WebMethod]
public XElement[] getXmlCompany()
{
return xmlCompany;
}
[WebMethod]
public XElement[] getXmlCandidate()
{
return xmlCandidate;
}
[WebMethod]
public XElement[] getXmlQualification()
{
return xmlQualification;
}
}
我想打電話給getXmlCompany
和任何從Company.aspx.cs其他方法,比如一個文件任何其他方法 - 如果可能的話
親切的問候
馬庫斯
您需要在調試器中啓動Web服務項目,然後轉到耗用它的項目並選擇添加Web引用。 –