Академический Документы
Профессиональный Документы
Культура Документы
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008
2. Agregar un proyecto web con el nombre de ServicioWeb. 3. Seleccionar como plantilla Servicio Web Asp.Net.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 4. Abrir del explorador de soluciones la clase con el nombre de service.vb.
5. Como usted puede observar esa clase contiene codigo generado por el mismo diseador. Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols ' Para permitir que se llame a este servicio web desde un script, usando ASP.NET AJAX, quite la marca de comentario de la siguiente lnea. ' <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://tempuri.org/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Public Class Service Inherits System.Web.Services.WebService <WebMethod()> _ Public Function HelloWorld() As String Return "Hello World" End Function End Class
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 6. Digitar el siguiente script dentro de la clase service.vb. <WebMethod()> _ Public Function DsTable() As Data.DataSet Try Using cn As New Data.SqlClient.SqlConnection("data source=.;database=importacionesneptuno;integrated security=true") Using da As New Data.SqlClient.SqlDataAdapter("select * from productos", cn) Dim ds As New Data.DataSet ds.Clear() da.Fill(ds, "Productos") da.SelectCommand.CommandText = "select * from clientes" da.Fill(ds, "Clientes") Return ds End Using End Using Catch ex As Exception Throw ex End Try End Function 7. Ejecutar el servicio web. 8. Copiar el url de la pagina.
9. Hacer clic dsTable. 10. Como usted puede observar se muestra el contenido de la tabla en formato XML.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 11. Agregar un proyecto de tipo Aplicaciones Windows y utilizar como lenguajes C#. 12. Asignar como nombre Consumiendo Servicio.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
13. Seleccionar el proyecto ConsumiendoServicio. 14. Pulsar el boton derecho del mouse y seleccionar la opcion agregar referencia web. 15. Aparecera un cuadro de dialogo. 16. Indicar la direccion de la URL que aparece al momento de ejecutar el web servis. 17. En nombre de la referencia web asignar localhost. 18. Finalmente hacer clic en agregar referencia.
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 19. Como usted puede observar se ha agregado una carpeta llamada Web References.
21. Declarar la siguiente variable dentro del formulario. localhost.Service svc = new localhost.Service(); 22. Digitar el siguiente script dentro del boton Tabla Productos. this.dataGridView1.DataSource = svc.DsTable().Tables[0]; 23. Digitar el siguiente script dentro del boton Tabla Clientes. this.dataGridView1.DataSource = svc.DsTable().Tables[1]; 24. Ejecutar la aplicacin.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 3. Digitar los siguientes metodos dentro de la clase. <WebMethod()> _ Public Function Suma(ByVal a As Int32, ByVal b As Int32) As Int32 Return a + b End Function <WebMethod()> _ Public Function Resta(ByVal a As Int32, ByVal b As Int32) As Decimal Return a - b End Function <WebMethod()> _ Public Function Multiplicacion(ByVal a As Int32, ByVal b As Int32) As Int32 Return a * b End Function <WebMethod()> _ Public Function Division(ByVal a As Int32, ByVal b As Int32) As Decimal Return a / b End Function 4. Ejecutar el servicio web y copiar la url del servicio.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 5. Ingresar ADOBE FLASH. 6. Disear la siguiente interfaz.
7. Hacer clic en el Menu Ventana > Otros Paneles > Servicio Web. 8. Como usted puede observar se muestra el panel llamado Servicio web.
9. Hacer clic en el simbolo Definir Servicios Web. 10. Hacer clic en la opcion Aadir O Quitar URL De Servicios Web.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 11. Como usted puede observar se muestra los metodos dentro del panel Servicios Web.
12. Seleccionar el metodo Suma. 13. Pulsar el boton derecho del mouse y hacer clic en la opcion aadir llamada de metodo.
14. Realizar el mismo procedmiento para el metodo resta. 15. Como usted puede observar se muestra un simbolo por cada metodo aadido al formulario. Captulo XVIII Creando y consumiendo Servicios web
16. Seleccionar el web servis que hace referencia al metodo suma y asignar como nombre de instancia suma_ws.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
10
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 17. Seleccionar el web servis y hacer clic en el menu ventana > inspector de componentes,para visualizar el panel con el mismo nombre. 18. Hacer clic en la ficha vinculacion.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
11
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008
21. Hacer clic en la opcion bound to. 22. Seleccionar como valor, la caja de texto con el nombre de instancia a_txt.
23. Realizar el mismo procedimiento para el parametro b. 24. Hacer clic en la opcion aadir vinculo. 25. Seleccionar la opcion results.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
12
Programacin en ASP.Net 3.5 y Acceso a Datos con Microsoft SQL Server 2008 26. Hacer clic en la opcion bound to. 27. Seleccionar el texto con el nombre de instancia lblResultado_txt. 28. Finalmente seleccionar el fotograma numero 1 e ir al panel acciones y digitar el siguiente script. var procesar:Object= new Object() procesar.click=function(){ suma_ws.trigger() } btnSuma.addEventListener("click",procesar) 29. ejecutar la aplicacin flash.
Instructor: Cueva Valverde Diego Alberto / DCE DCEG DCEP MCTS / dce.diegocueva@gmail.com
13