A
adal
I have an app read location from external GPS and send request to a
webservice server using lat and longti as an input.
I use SerialPort class(c#, CF2.0) to read data from GPS, and it works
fine. However, after my serial port is opened. My webservice request
is always failed and I got an exception "Unable to connect to the
remote server". Here is my code:
private void Connect_Click(object sender, EventArgs e)
{
string[] ports = SerialPort.GetPortNames();
_serialPort = new SerialPort(ports[0]);
_serialPort.ReadTimeout = 5000;
_continue = true;
_serialPort.Open();
Thread readThread = new Thread(SerialRead);
readThread.Start();
}
private void SerialRead()
{
while (_continue)
{
string Sentence = _serialPort.ReadLine();
Thread.Sleep(1000);
}
}
private void Disconnect_Click(object sender, EventArgs e)
{
_continue = false;
_serialPort.Close();
}
private void Webservice_Click(object sender, EventArgs e)
{
try
{
WebReference.ContentControlService webService = new
GPSTest.WebReference.ContentControlService();
webService.contentSearch("xxxx");
}
catch (Exception pe)
{
MessageBox.Show(pe.Message);
}
}
Thank you very much in advance for your sugession and hits.
Adal
webservice server using lat and longti as an input.
I use SerialPort class(c#, CF2.0) to read data from GPS, and it works
fine. However, after my serial port is opened. My webservice request
is always failed and I got an exception "Unable to connect to the
remote server". Here is my code:
private void Connect_Click(object sender, EventArgs e)
{
string[] ports = SerialPort.GetPortNames();
_serialPort = new SerialPort(ports[0]);
_serialPort.ReadTimeout = 5000;
_continue = true;
_serialPort.Open();
Thread readThread = new Thread(SerialRead);
readThread.Start();
}
private void SerialRead()
{
while (_continue)
{
string Sentence = _serialPort.ReadLine();
Thread.Sleep(1000);
}
}
private void Disconnect_Click(object sender, EventArgs e)
{
_continue = false;
_serialPort.Close();
}
private void Webservice_Click(object sender, EventArgs e)
{
try
{
WebReference.ContentControlService webService = new
GPSTest.WebReference.ContentControlService();
webService.contentSearch("xxxx");
}
catch (Exception pe)
{
MessageBox.Show(pe.Message);
}
}
Thank you very much in advance for your sugession and hits.
Adal