Hello
I have two web services on two different servers communicating
WS1.asmx
WS2.asmxCode:<%@ WebService Language="VB" Class="WS1" %> Imports System Imports System.Web Imports System.Web.Services Imports System.Xml.Serialization Imports System.Net Imports System.IO ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://www.test.com/ws")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ Public Class WS1 Inherits System.Web.Services.WebService Dim IP as String = "192.168.0.174" <WebMethod()> _ Public Function Function1(ByVal s1 As String) As String Dim ReturnString As String = "" Try Dim soap As String = "<?xml version=""1.0"" encoding=""utf-8""?><soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""><soap:Body><Function2 xmlns=""http://www.test.com/ws""><s2>" & s1 & "</s2></Function2></soap:Body></soap:Envelope>" Dim req As HttpWebRequest = WebRequest.Create("http://" & IP & "/WS2.asmx") req.Headers.Add("SOAPAction", "http://www.test.com/ws/Function2") req.ContentType = "text/xml;charset=\utf-8\" req.Accept = "text/xml" req.Method = "POST" Using stm As Stream = req.GetRequestStream() Using stmw As New StreamWriter(stm) stmw.Write(soap) End Using End Using Dim response As WebResponse = req.GetResponse() Dim responseStream As Stream = response.GetResponseStream() Dim s_read As New System.IO.StreamReader(responseStream) ReturnString = s_read.ReadToEnd s_read.Close() ReturnString = Replace(ReturnString, "<?xml version=""1.0"" encoding=""utf-8""?><soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><soap:Body><Function2Response xmlns=""http://www.test.com/ws""><Function2Result>", "") ReturnString = Replace(ReturnString, "</Function2Result></Function2Response></soap:Body></soap:Envelope>", "") Catch ex As Exception ReturnString = ex.Message End Try Return ReturnString End Function End Class
WS1 calls a function in WS2, my problems is what if the communication between the two servers goes down, is there any way to keep re-trying for a certain time out period (2 minutes suppose) ??Code:<%@ WebService Language="VB" Class="WS2" %> Imports System Imports System.Web Imports System.Web.Services Imports System.Xml.Serialization ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://www.test.com/ws")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ Public Class WS2 Inherits System.Web.Services.WebService <WebMethod()> _ Public Function Function2(ByVal s2 As String) As String Dim ReturnString As String = "" Try ReturnString = "Hello " & s2 Catch ex As Exception ReturnString = ex.Message End Try Return ReturnString End Function End Class
Thank you




Reply With Quote