0
Reply

Handle socketexception error to try reconnecting?

brian wetherell

brian wetherell

Jan 11 2010 2:51 PM
5k

I have a function that posts to a web service and handles a response.  This web service has proven someone unreliable in that the server becomes unresponsive after transmitting several hundred posts (and handling the responses).  As a result, I need to know how to handle the socket exception error (system.net.sockets.socketexception) so that it will try to post the record again.  Here's a sample of the code I have;
 

 
Try
 
'For each item number in array, the following process is observed...
For Each i As String In ItemData
 
'Post XML to web service
post =
"<XMLFORMPOST><REQUEST>availability</REQUEST><LOGIN><USERID>" _
& userid &
"</USERID><PASSWORD>" & pass & "</PASSWORD></LOGIN><PARTNUM>" _
& i &
"</PARTNUM></XMLFORMPOST>"
 
'retreive txt/xml response & pass to appropriate function
Response = EasyHttp.Send(xmlurl, post, HTTPMethod.HTTP_POST,
"text/xml")
 
Next
 
Catch
SocketEx As System.Net.Sockets.SocketException
   'Socket Exception handler goes here
 

Catch
SockeetEx As Exception
   Throw Ex
End Try