JavaScript - No realiza peticion post de servicio

 
Vista:

No realiza peticion post de servicio

Publicado por Carlos Guerra Cubillo (2 intervenciones) el 07/11/2017 10:26:49
Al utilizar el servicion getLugares no dispara peticion http, no se porque, la infraestructura si funciona con jmeter, no funciona ninguno de los servicios

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Injectable }     from '@angular/core';
import { Http, Headers,Response } from '@angular/http';
import {Observable} from 'rxjs';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
@Injectable()
export class LugaresService {
   // private instance variable to hold base url
  private serviceUrl = 'http://127.0.0.1:8080/ProgramaHospitalServicios/service';
  // Resolve HTTP using the constructor
	constructor (private http: Http) {}
 
	public getLugares(){
	    var data:any = {};
	    const headers = new Headers({"Content-Type":"application/json"});
	    debugger;
	    var body:any = {
	      "service":"getLugares",
	      "params": {}
	    };
	    this.http.post(this.serviceUrl, body, {headers:headers})
	      .map((resultado)=> {
	        console.log(resultado);
	        debugger;
	        data = resultado.json().lugares;
	        debugger;
	        console.log(data);
	      } )
	      .catch(this.handleError); // Trouble line.
	      return data;
	}
 
	public handleError(error: Response) {
	    console.error(error);
	    return Observable.throw(error.json().error || 'Server error');
	}
	public buscarLugar(id){
	    console.log(id);
	    const headers = new Headers({"Content-Type":"application/json"});
	    var body:any = {
		    "service":"getLugar",
		    "params": {
                   "id":id
                }
	    };
	    debugger;
	    this.http.post(this.serviceUrl, body, {headers:headers})
	      .map((resultado)=> {
	        const data = resultado.json().lugar;
	        console.log(data);
	        return data;
	      })
	}
	public guardarLugar(lugar){
	    console.log(lugar);
	    const headers = new Headers({"Content-Type":"application/json"});
	    var body:any = {
		    "service":"putLugares",
		    "params": {
                   "nombre": lugar.nombre,
                   "cercania": lugar.cercania,
                   "distancia": lugar.distancia,
                   "descripcion": lugar.descripcion,
                   "plan": lugar.plan
                }
	    };
	    debugger;
	    this.http.post(this.serviceUrl, body, {headers:headers})
	    .map((resultado)=> {
	        const data = resultado.json().lugares;
	        console.log(data);
	        return data;
	    })
	}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

No realiza peticion post de servicio

Publicado por Carlos Guerra Cubillo (2 intervenciones) el 07/11/2017 10:43:09
El framework es ANGULAR 4
La infraestructura es java / servlets pero eso no importa
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar