I have read couple of posts in this forum with respect to this subject but i am facing problems that is why i decided to ask you once more. I am new to netduino and MF and i want your advices. I have created a WCF web service that i would like to access it from netduino in order to record my temperature readings from a sensor. I would prefer if i could use no 3rd party framework and i would like if it is possible to give me some hints for the code. First of all i would like to know if i can access REST WCF services from netduino?
My netduino code is:
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; using System.Net.Sockets; using System.IO; using System.Text; namespace NetduinoPlusApplication1 { public class Program { public static void Main() { // write your code here OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); var sw1 = new InputPort(Pins.ONBOARD_SW1,false,Port.ResistorMode.Disabled); while (true) { if(!sw1.Read()) { led.Write(!led.Read()); Thread.Sleep(500); string message = "<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">23</string>"; byte[] byteArray = UTF8Encoding.UTF8.GetBytes(message); HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://10.1.8.131/TemperatureService/ShowTemperature.svc/GetTemperature/56"); myReq.Method = "GET"; HttpWebResponse WebResp = (HttpWebResponse)myReq.GetResponse(); } } } } }
According to my WCF service when i write (http://localhost/Tem...tTemperature/42) in browser i get a string as output with the temp. that i recorded i.e. 42 deg. of celcius recorded OK.
The problem that i am facing is that when i run the code in netduino there is nothing after the GetResponse i.e. the netduino freezes. How can i get the output from the WCF web service?
Thank you in advance.
Edited by Stefan, 27 August 2012 - 11:09 AM.
Added [code] tags