搞混了,我敢肯定这是一个愚蠢的。解决方案:
项目 1.公司。 Linea.cs:只是具有不同构造函数的Linea类,现在就是这样。
项目 2. Bandeja。 Class.cs:在这里,我编写了使用Linea时需要的所有方法。(getLinea() 是我将在下面的示例中向您展示的那个)
项目 3. WCFWebService。 调用 C# 方法的 WCF 服务。
参考。
从班德哈到康帕尼亚。
从 WCFWebService 到 Compania。
从 WCFWebService 到 Bandeja。
我在构建时遇到的唯一一个错误来自服务。
服务等级
namespace WCFWebService
{
[DataContract]
public class WSBandeja : IWSBandeja
{
public Compania.Linea getLinea()
{
Compania.Linea linea = new Compania.Linea();
return linea.
}
}
}
当我输入 return.linea。我在 Project Bandeja 的 class.cs 中找不到方法 getLinea(),只有参数。
任何建议都是最受欢迎的,因为我是 C# 和 WebServices 的新手。谢谢。
编辑。公司项目 - Linea.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Compania
{
public class Linea
{
public string ani { get; set; }
public int teleprom { get; set; }
public string actividad { get; set; }
public DateTime fechaIngreso { get; set; }
public string reclamo { get; set; }
public string producto { get; set; }
public string observacion { get; set; }
public int tipoActividad { get; set; }
public string tipoAveria { get; set; }
public int reiteros { get; set; }
public int call { get; set; }
public bool trabajado { get; set; }
}
}
Bandeja 项目 - Class.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Web;
namespace Bandeja
{
public class Bandeja
{
public static string getNewConnection()
{
return ConfigurationManager.ConnectionStrings["BO"].ConnectionString;
}
public Compania.Linea getLinea()
{
var cLinea = new Compania.Linea();
string connectionString = getNewConnection();
SqlConnection conn = new SqlConnection(connectionString);
using(conn)
{
string variable = "GESTIONAR MANUALMENTE";
var command = new SqlCommand("Bandeja_test");
command.Connection = conn;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@linea", variable));
conn.Open();
SqlDataReader newReader = command.ExecuteReader();
while (newReader.Read())
{
cLinea = new Compania.Linea();
cLinea.ani = newReader["Línea"].ToString();
cLinea.fechaIngreso = Convert.ToDateTime(newReader["Fecha Ingreso"]);
cLinea.producto = newReader["Producto"].ToString();
cLinea.observacion = newReader["Observación"].ToString();
}
}
return cLinea;
}
}
}
Web 服务接口。
namespace WCFWebService
{
[ServiceContract]
public interface IWSBandeja
{
[OperationContract]
Compania.Linea getLinea();
}
}