I have been trying to create a SOAP request using VBA but everytime I am getting a blank 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
In SOAP web service, each HTTP request or response encapsulates a SOAP envelope, these messages are easy to trace by using Eclipse IDE, build-in “TCP/IP monitor” tool. The idea is host another server in between the client and server to perform port forward function to intercept the HTTP traffic.
The SOAP Request and Response binding method uses SOAP to bind to a server. SOAP is a lightweight protocol for data exchange in a distributed environment and consists of: An envelope that defines a framework for describing what is in a message and how to process it.
A SOAP response message is sent by the SOAP provisioning client in response to a SOAP request. Each response contains a series of ASCII characters.
You definitely have a mistake in the line:
objHttp.Open "GET", sURL, False
which should be replaced by:
objHttp.Open "POST", sURL, False
This error won't let you go forward. After you correct this, it is possible that you have to debug the soap message. So, after you change this, you can tell us how it goes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With