Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Problema con http connection

    Ciao a tutti

    ho scritto un applicazione per windows mobile 6.1 professional e mi sta dando qualche rogna nell'invio di dati tramite http post.
    Il codice in questione è:
    void DoConnect(string url) {

    string rmc = "Dati GPS RMC non disponibili";
    string gga = "Dati GPS GGA non disponibili";

    if (!this.gpsPosRMC.Equals("")) {
    rmc = this.gpsPosRMC;
    }

    if (!this.gpsPosGGA.Equals("")) {
    gga = this.gpsPosGGA;
    }
    try
    {

    //this.WriteInFile("&deviceId= " + this.deviceId + "&rmc= " + rmc + "&time= " + System.DateTime.Now);

    // Create a request using a URL that can receive a post.
    WebRequest request = WebRequest.Create(url);
    // Set the Method property of the request to POST.
    request.Method = "POST";
    // Create POST data and convert it to a byte array.
    string postData = "&deviceId= " + this.deviceId + "&rmc= " + rmc + "&gga= " + System.DateTime.Now;
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    // Set the ContentType property of the WebRequest.
    request.ContentType = "application/x-www-form-urlencoded";
    // Set the ContentLength property of the WebRequest.
    request.ContentLength = byteArray.Length;

    // Get the request stream.
    Stream dataStream = request.GetRequestStream();
    // Write the data to the request stream.

    dataStream.Write(byteArray, 0, byteArray.Length);
    // Close the Stream object.
    dataStream.Close();


    }
    catch (Exception e) {
    this.WriteInFile("doconnect:::::"+e.Message);
    //this.WriteInFile("doConnect"+e.Message);
    }
    }


    Chiamando questo metodo riesco a contattare il server 2-3 volte poi mi si impalla generando quest'eccezione:

    in System.Net.HttpWebRequest.finishGetRequestStream()
    in System.Net.HttpWebRequest.GetRequestStream()
    in DeviceApplication2.Form1.DoConnect()
    in DeviceApplication2.Form1.button3_Click()
    in System.Windows.Forms.Control.OnClick()
    in System.Windows.Forms.Button.OnClick()
    in System.Windows.Forms.ButtonBase.WnProc()
    in System.Windows.Forms.Control._InternalWnProc()
    in Microsoft.AGL.Forms.EVL.EnterMainLoop()
    in System.Windows.Forms.Application.Run()
    in DeviceApplication2.Program.Main()

    Ho provato anche a lanciarla su windows(.exe) e funziona alla grande ma appena produco il .CAB mi funziona per 2-3 volte poi mi si impalla lanciando l'eccezione di sopra!!!!!
    AIUTO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!
    Grazie anticipatamente

  2. #2
    Risolto!!!!!!!!!!!!!!!!!!!!!!!
    Ho modificato il codice semplificandolo ve lo posto magari è di aiuto a qualcuno!!!!


    [CODE] public void sendHttpData()
    {
    string rmc = "Dati GPS RMC non disponibili";
    string gga = "Dati GPS GGA non disponibili";

    if (!this.gpsPosRMC.Equals("")) {
    rmc = this.gpsPosRMC;
    }

    if (!this.gpsPosGGA.Equals("")) {
    gga = this.gpsPosGGA;
    }
    try
    {
    string sURL = "http://10.64.32.99:8080/GpsByGprs/GpsDataReciver?deviceId="+this.deviceId+"&rmc="+rm c+"&gga="+gga;

    WebRequest wrGETURL = WebRequest.Create(sURL);

    Stream objStream = wrGETURL.GetResponse().GetResponseStream();
    objStream.Close();
    }
    catch(Exception e)
    {
    this.WriteInFile("sendHttpData:::::" + e.Message);
    }

    }


    Se ci sono domande scrivete pure!!!!
    Ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.