创建WebService [英] Creating a WebService
问题描述
我正在尝试创建一个Web服务,我已经查看了所有不同的教程,但我似乎无法掌握它。有人能帮我吗?这就是我想要做的事情;
创建一个Web服务,允许用户输入SMS样式的缩写,并返回扩展的含义。从逗号分隔的文本文件填充,包含SMS样式的缩写,以及它们的扩展含义
使用字典类来保存SMS缩写列表及其在英语中的含义
创建一个使用Web服务的应用程序。
我有一些代码,但我不确定如何在网络服务中导入/使用它。这是我目前的代码;
Hi,
I'm trying to create a webservice and I've looked at all different tutorials but I just can't seem to grasp it. Can someone help me? This is what I'm trying to do;
Create a Webservice that allows the user to enter SMS-style abbreviations, and returns the expanded meaning. Populated from a comma separated text file containing SMS-style abbreviations, and their expanded meaning
use a Dictionary Class to hold a list of SMS abbreviations and their meanings in English
Create an application that consumes the webservice.
I have some code but I'm unsure how to import/use it in a webservice. This is the code I currently have;
private string dirCSV;
private string fileNevCSV;
public string FileNevCSV
{
get { return fileNevCSV; }
set { fileNevCSV = value; }
}
public string dirCSV
{
get { return dirCSV; }
set { dirCSV = value; }
}
public DataSet loadCVS(int noofrows)
{
DataSet ds = new DataSet();
try
{
string strConnString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + this.dirCSV.Trim() +
";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string sql_select;
OdbcConnection conn;
conn = new OdbcConnection(strConnString.Trim());
conn.Open();
if (noofrows == -1)
{
sql_select = "select * from [" + this.FileNevCSV.Trim() + "]";
}
else
{
sql_select = "select top " + noofrows + " * from [" + this.FileNevCSV.Trim() + "]";
}
OdbcDataAdapter obj_oledb_da = new OdbcDataAdapter(sql_select, conn);
obj_oledb_da.Fill(ds, "csv");
/
conn.Close();
}
catch (Exception e) //Error
{
}
return ds;
}
this.dirCSV = "file path";
this.fileNevCSV ="file name";
DataSet ds = loadCVS(-1);
DataTable table = ds.Tables[0];
foreach (DataRow row in table.Rows)
任何人都可以帮我创建吗?或者指出一个好的方向?
Can anyone help me create this? Or point me in the direction of a good source?
推荐答案
我真的看不出你的问题所在。这听起来像一个简单的Web服务,只有一个WebMethod接受一个字符串并返回一个字符串。如果您在创建WebService时遇到问题,我建议您从这个很好的教程开始:您的第一个C#网络服务 [ ^ ]
PS:我看,这是你的作业,所以挣扎一下,如果你卡住了就来这里更具体的一步。
I really cant't see where your problem is. This sounds like a simple web service with a single WebMethod accepting a string and returning a string. If you have trouble creating a WebService, I suggest you start with this nice tutorial: Your first C# Web Service[^]
PS: as I see, this is your homework, so struggle a little bit, and come here if you stuck at a more concrete step.
这篇关于创建WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!