#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "THINKPAD 8969";
const char* password = "76grt@gfy";
//const char* serverUrl = "http://192.168.234.40/WSRaspBerry.asmx/InsertarDatosRaspberry";
const char* serverUrl = "http://192.168.137.1/A12/WSp/WSRp.asmx?op=InsertVeri";
const char* placa = "2555ASS";
const char* CO2 = "5455FFF";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Conectando a WiFi...");
}
Serial.println("Conectado a WiFi");
HTTPClient http;
http.begin(serverUrl);
// Establece el tipo de contenido como texto/xml
http.addHeader("Content-Type", "text/xml");
// Construye el cuerpo de la solicitud SOAP
//String requestBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
//requestBody += "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">";
//requestBody += "<soap12:Body>";
//requestBody += "<InsertarDatosRaspberry xmlns=\"http://tempuri.org/\">";
//requestBody += "<placa>" + String(placa) + "</placa>";
//requestBody += "<sensor>" + String(sensor) + "</sensor>";
//requestBody += "</InsertarDatosRaspberry>";
//requestBody += "</soap12:Body>";
//requestBody += "</soap12:Envelope>";
String requestBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
requestBody += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
requestBody += "<soap:Body>";
requestBody += "<InsertVeri xmlns=\"http://tempuri.org/\">";
requestBody += "<placa>" + String(placa) + "</placa>";
requestBody += "<CO2>" + String(CO2) + "</CO2>";
requestBody += "</InsertVeri>";
requestBody += "</soap:Body>";
requestBody += "</soap:Envelope>";
// Ejecuta la solicitud POST
int httpCode = http.POST(requestBody);
if (httpCode > 0) {
String response = http.getString();
Serial.println("Código de respuesta HTTP: " + String(httpCode));
Serial.println("Respuesta: " + response);
} else {
Serial.println("Error en la solicitud HTTP");
}
http.end();
}
void loop() {
// Tu código aquí, si es necesario
}