Ver Mensaje Individual
  #7 (permalink)  
Antiguo 26/11/2008, 06:30
lemope
 
Fecha de Ingreso: marzo-2005
Mensajes: 11
Antigüedad: 19 años, 1 mes
Puntos: 0
Exclamación Respuesta: Web Services y Web References

Hola, que tal, hice un Servicio Web en C#2008 el cual se comunica con una DB sql y lo que hace solo es desplegar los datos contenidos en dicha tabla.

Lo que quiero saber es como puedo mandar llamar el web service desde otra pagina, no desde una aplicacion de windows (es posible esto? tal vez suene tonto pero no conozco el tema bien) se que puedo hacer una aplicación cliente pero no tengo idea como y espero me puedan ayudar. Gracias!

pongo mi codigo por si ayuda de algo a alguien...

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;
using System.Configuration;

namespace Service1
{

[WebService(Namespace = "http://www.in2.es/",Description="Acceso a DB desde un WS")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// 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 Service1 : System.Web.Services.WebService
{
//private SqlConnection cnn;
private SqlDataAdapter da;
private SqlCommand sqlSelectCommand;
//private DataSet ds = new DataSet();
public Service1()
{

//
//sqlSelectCommand = new SqlCommand();
//cnn = new SqlConnection();
//da = new SqlDataAdapter();
//cnn.ConnectionString = "integrated security=SSPI;data source=(local);initial catalog=Northwind";
//sqlSelectCommand.CommandText = "SELECT LastName, FirstName, Title, BirthDate FROM Employees";
//sqlSelectCommand.Connection = cnn;
//da.SelectCommand = sqlSelectCommand;
}
//
[WebMethod(Description = "Devuelve datos de DB")]
public DataSet Empleados(string select)
{
//cnn = new SqlConnection();
da = new SqlDataAdapter();

string cnnProd = ConfigurationManager.ConnectionStrings[1].ConnectionString;
SqlConnection cnn = new SqlConnection(cnnProd);


//cnn.ConnectionString = "integrated security=SSPI;data source=(local);initial catalog=Northwind";
sqlSelectCommand = new SqlCommand();
if (!(select == null))
sqlSelectCommand.CommandText = "select * from pruebas";
//sqlSelectCommand.CommandText = select;
else
sqlSelectCommand.CommandText = "select * from pruebas";
//sqlSelectCommand.CommandText = "SELECT LastName, FirstName, Title, BirthDate FROM Employees";
//
DataSet ds = new DataSet();
try
{
sqlSelectCommand.Connection = cnn;
da.SelectCommand = sqlSelectCommand;
da.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
return ds;
}
}
}


Muchas gracias "len"