Unable to get response from web service via SOAP request using VBA

I am trying to create a SOAP request using VBA, but every time I get an empty response. Please find the code below. WSDL URL: http://productavailabilityfeed.xxxx.com/Availability.svc?wsdl

Dim sURL As String Dim sEnv As String 'Set and Instantiate our working objects Set objHttp = CreateObject("MSXML2.XMLHTTP") sURL = "http://productavailabilityfeed.xxxx.com/Product.svc/soap" ' we create our SOAP envelope for submission to the Web Service 'sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>" 'sEnv = sEnv & "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope"">" sEnv = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">" sEnv = sEnv & " <soap:Header>" sEnv = sEnv & " <soap:Body>" sEnv = sEnv & " <tem:GetAccommodationByCode>" sEnv = sEnv & " <!--Optional:-->" sEnv = sEnv & " <tem:getAccommodationByCodeRequest>" sEnv = sEnv & " <!--Optional:-->" sEnv = sEnv & " <tem:credentials>" sEnv = sEnv & " <!--Optional:-->" sEnv = sEnv & " <tem:username>?</tem:username>" sEnv = sEnv & "<!--Optional:-->" sEnv = sEnv & "<tem:password>?</tem:password>" sEnv = sEnv & "</tem:credentials>" sEnv = sEnv & "<!--Optional:-->" sEnv = sEnv & "<tem:accommodationCode>?</tem:accommodationCode>" sEnv = sEnv & "<!--Optional:-->" sEnv = sEnv & "<tem:imageSize></tem:imageSize>" sEnv = sEnv & "<!--Optional:-->" sEnv = sEnv & "<tem:interval></tem:interval>" sEnv = sEnv & "</tem:getAccommodationByCodeRequest>" sEnv = sEnv & "</tem:GetAccommodationByCode>" sEnv = sEnv & "</soapenv:Body>" sEnv = sEnv & "</soapenv:Envelope>" 'we invoke the web service 'use this code snippet to invoke a web service which requires authentication objHttp.Open "GET", sURL, False objHttp.setRequestHeader "Content-Type", "text/xml" objHttp.setRequestHeader "SOAPAction", "http://tempuri.org/xxxx/GetAccommodationByCode" objHttp.send sEnv MsgBox objHttp.responseText 'clean up code Set objHttp = Nothing Set XMLDOC = Nothing 
+6
source share
1 answer

You definitely have an error in the line:

 objHttp.Open "GET", sURL, False 

which should be replaced by:

 objHttp.Open "POST", sURL, False 

This mistake will not allow you to go forward. After you fix this, you may need to debug the soap message. So, after you change this, you can tell us how this happens.

+1
source

All Articles