Quantcast
Viewing all articles
Browse latest Browse all 21342

How to set timeout for web service operation using MSXML2.XMLHTTP

Hi mates,

I have below code that works fine but i have to set a timeout for the web service call. Any suggestions please? Thank in advance.

Code:

Dim objDom As Object
        Dim objXmlHttp As Object
        Dim strXml As String
        Dim strSoapAction As String
        Dim strUrl As String
        Dim strRet As String
       
        strUrl = "http://ip/WS_EndPoint_Link"
        strSoapAction = "http://tempuri.org/GetMessage"

        strXml = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/""        "&_
                          "xmlns:tem=""http://tempuri.org/"">" &_
                            "<soapenv:Header/><soapenv:Body><tem:GetMessage><!--Optional:--><tem:pMessage>GDT~AL</tem:pMessage></tem:GetMessage></soapenv:Body></soapenv:Envelope>"

          Set objDom = CreateObject("MSXML2.DOMDocument")
        Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")

        ' Load XML
        objDom.async = False
    objDom.loadXML strXml

        ' Open the webservice
    objXmlHttp.open "POST", strUrl, False

        ' Create headings
    objXmlHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
    objXmlHttp.setRequestHeader "SOAPAction", strSoapAction

        ' Send XML command
    objXmlHttp.send objDom.xml

        ' Get all response text from webservice
    strRet = objXmlHttp.responseText

        ' Close object
    Set objXmlHttp = Nothing

'iApp.UserMsg "strRet" & strRet
        intPos1 = InStr(strRet, "GetMessageResult") + 21
    intPos2 = InStr(intPos1, strRet, "</")
    dateTime = Mid(strRet, intPos1, (intPos2 - intPos1))


Viewing all articles
Browse latest Browse all 21342

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>