开发者

First web service call through WLAN is raising an exception in Wince 5.0

I have developed a application that run on a开发者_运维问答 device with Wince 5.0. I make web service calls using WLAN. The application works fine if the app server is with the LAN. In the other case, it raises a exception only for the first time when the application tries to communicate with the appserver. If the application is launched for the second time it does not raise any exception.

The stack trace:

Tuesday, April 13, 2010 - 10:03:04 AM: Unable to connect to the remote server at System.Net.HttpWebRequest.finishGetResponse() at System.Net.HttpWebRequest.GetResponse() at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult) at Aarya.Service.MIDServiceProxy.ManagementService.MIDAuthenticateLoginandRole(String sUsername, String sPassword) at Aarya.Modules.MID.ProxyWrapper.ManagementServiceWrapper.MIDAuthenticateLoginandRole(String sUsername, String sPassword) at Aarya.MID.AuthenticateManager.Logon(String loginName, String password) at Aarya.MID.Shell.PerformAsyncLogin()


A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.Socket.ConnectNoCheck(EndPoint remoteEP) at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) at System.Net.Connection.doConnect(IPEndPoint ep) at System.Net.Connection.connect(Object ignored) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()


My guess is that the first time it is launched you don't have a network connection. Your web service call then calls down into connection manager, which then powers up the radio, contacts the DHCP server, gets an address, then creates the network connection.

All of this process is probably taking too long and your app time's out. Once you've made the first call, Connection Manager keeps that connection open for a while and your second run uses that existing connection, so it succeeds.

Your app needs to be handling timeouts anyway (what if the network is out of range or unreachable), so proper situation handling should take care of this anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜