Send URL

Last post 12-13-2007 4:36 by Anonymous. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 12-12-2007 2:45

    Send URL

    Hi.
    I want to send to an url some information. This information is changing every few seconds.
    In java I do:

    String Url="http://138.4.40.11:8080/damehuella/getHuella";

    URL gatewayUrl = new URL (Url+"?mac="+macad+"&132b="+huellap[0]+"&133b="
    +huellap[1]+"&136b="+huellap[2]+"&1320b="+huellap[3]);

    URLConnection connection = gatewayUrl.openConnection();

    Is possible to do the same using c#. Thnak you very much
  • 12-12-2007 4:34 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: Send URL

    Yes, it is possible. See HttpWebRequest for details.

    Neil Cowburn
    Principal Partner
    OpenNETCF Consulting, LLC

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • 12-12-2007 5:03 In reply to

    Re: Send URL

    Thanks

    I put:


    String Url = "http://138.4.40.11:8080/damehuella/getHuella";

    Uri gatewayUrl = new Uri(Url + "?mac=" + macad + "&132b=" + huellap[0] + "&133b="+ huellap[1] + "&136b=" + huellap[2] + "&1320b=" + huellap[3]);

    HttpWebRequest connection=(HttpWebRequest)HttpWebRequest.Create(gatewayUrl);

    But this don't run well.
  • 12-13-2007 1:51 In reply to

    Re: Send URL

    Hi.
    I only want to change the url.
    I also put:
    HttpWebRequest connection=(HttpWebRequest)HttpWebRequest.Create(gatewayUrl);
    connection.Connection="SET";

    Could someone help me?
  • 12-13-2007 2:23 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: Send URL

    There are literally tens of thousands of samples on the web if you search for them.

    Neil Cowburn
    Principal Partner
    OpenNETCF Consulting, LLC

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • 12-13-2007 2:43 In reply to

    Re: Send URL

    Thank you.
    Of course I have read a lot of samples. But always send or get dato. I don't want to do this, I only want to change the url each few seconds.
    Thank you very much.
  • 12-13-2007 3:39 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: Send URL

    Please describe in more detail exactly what you are trying to achieve.

    Neil Cowburn
    Principal Partner
    OpenNETCF Consulting, LLC

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • 12-13-2007 3:51 In reply to

    Re: Send URL

    OK.
    I have a program to access signal strength on a wifi network. When I have this data (huellap[]), I must send it to an URL. I call to a servlet on a Tomcat server with this url:


    String Url = "http://138.4.40.11:8080/damehuella/getHuella";
    Uri gatewayUrl = new Uri(Url + "?mac=" + macad + "&132b=" + huellap[0] + "&133b="
    + huellap[1] + "&136b=" + huellap[2] + "&1320b=" + huellap[3]);

    After the Tomcat send a xml to confim.

    And all of thison an infinite loop. Each 2 seconds I send another data. Thank you.
  • 12-13-2007 4:02 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: Send URL

    string xmlResultAsString = null;

    // Construct the URL
    string UrlFormat = "http://138.4.40.11:8080/damehuella/getHuella{0}";
    string url = string.Format(UrlFormat, "?mac="+macad+"&132b="+huellap[0]+"&133b="+huellap[1]+"&136b="+huellap[2]+"&1320b="+huellap[3]);

    // Create and issue the HTTP request
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    HttpWebResponse response = request.GetResponse();

    // Retrieve the XML data as string
    // If you don't care about the XML that is returned
    // by the Tomcat server, then you can ignore this bit
    if (response.StatusCode == HttpStatusCode.OK)
    {
    using (StringReader reader = new StringReader(response.GetResponseStream()))
    {
    xmlResultAsString = reader.ReadToEnd();
    }
    }

    // Now you can do whatever you need to do with the XML
    // e.g. load it into a DOM object


    Neil Cowburn
    Principal Partner
    OpenNETCF Consulting, LLC

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • 12-13-2007 4:36 In reply to

    Re: Send URL

    Thank you.
    I have found my mistake. It was because huellap don't change well.
    Thank you very much
Page 1 of 1 (10 items)