La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

SERVICIO WEN EN.NET. 1) Se crea el servicio web.

Presentaciones similares


Presentación del tema: "SERVICIO WEN EN.NET. 1) Se crea el servicio web."— Transcripción de la presentación:

1 SERVICIO WEN EN.NET

2 1) Se crea el servicio web

3

4

5 Servicio 1 [WebMethod] public double restar(string dato1, string dato2) { return Convert.ToDouble(dato1) - Convert.ToDouble(dato2); }

6 Servicio 2 [WebMethod] public System.Data.DataSet Consultar() { string mensaje; System.Data.OleDb.OleDbConnection conn; try { conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=D:\docentes.mdb"; conn.Open(); string sentenciaSQL1; sentenciaSQL1 = "SELECT * FROM DOC "; System.Data.OleDb.OleDbDataAdapter objRes; objRes = new System.Data.OleDb.OleDbDataAdapter(sentenciaSQL1, conn); System.Data.DataSet datos; datos = new System.Data.DataSet(); objRes.Fill(datos, "Tabla"); mensaje = "Todo OK"; return datos; } catch (Exception MiExc) { System.Data.DataSet datos2; datos2 = new System.Data.DataSet(); mensaje = "Se presento el Siguiente Error " + MiExc.Message; return datos2; }

7 Servicio 3. [WebMethod] public string consultar(string ced) { int seleccionados; System.Data.OleDb.OleDbConnection ObjConn; ObjConn = new System.Data.OleDb.OleDbConnection(); string consunom; ObjConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=D:\docentes.mdb"; consunom = @"SELECT * FROM DOC WHERE ID_D='" + ced + "'"; System.Data.OleDb.OleDbDataAdapter objSql2; objSql2 = new System.Data.OleDb.OleDbDataAdapter(consunom, ObjConn); System.Data.DataSet ds2; ds2 = new System.Data.DataSet(); objSql2.Fill(ds2, "tabla1"); seleccionados = ds2.Tables["tabla1"].Rows.Count; if (seleccionados == 0) { return " No se encuentra el nombre "; } else { return (string)ds2.Tables["tabla1"].Rows[0]["NOMBRES"]; }

8

9 WSDL

10 Prueba y SOAP

11

12 Es necesario publicar el servicio. Se crea una carpeta física en el disco Se publica el servicio en esta carpeta(clic derecho en el administrador de soluciones) En herramientas administrativas de IIS se crea un directorio virtual y se enlaza con la carpeta física donde se publico el servicio.

13

14

15

16

17

18

19 Consumir el servicio Es posible consumir el servicio desde un aplicación windows o web.

20

21

22

23

24 En el evento clic del boton: private void button1_Click(object sender, EventArgs e) { pepe.ServiceSoapClient miobj = new pepe.ServiceSoapClient(); label1.Text = miobj.consultar_uno(textBox1.Text); }

25

26

27 Se crea un aplicación java Se agrega un formulario Consumo en java

28

29

30

31

32

33 EN EL EVENTO DEL BOTON: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { org.tempuri.Service service = new org.tempuri.Service(); org.tempuri.ServiceSoap miobj = service.getServiceSoap(); jLabel2.setText(miobj.consultarUno(jTextField1.getText() )); // TODO add your handling code here: }

34

35


Descargar ppt "SERVICIO WEN EN.NET. 1) Se crea el servicio web."

Presentaciones similares


Anuncios Google