Does WEBSERVICE(url) work for SOAP based Web services?

spehe

New Member
Joined
Oct 22, 2010
Messages
10

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Using VBA, you can "POST" your SOAP request to the server by the "MSXML2.XMLHTTP" object and and then parse the returned XML table to retrieve your data.
 
Upvote 0
Thank you for your reply. As a matter of fact that is what I am trying to do. I am using this vba code I copied from an old post, and I have modified it for my usage. But it gives me an error on the line with 'Set objHTTP = New MSXML2.XMLHTTP'. Error message is 'Compiling error: Own designed tpe has not been defined'....
Sub InvokeAuthenticate()
'Declare our working variables
Dim sMsg As String
Dim sURL As String
Dim sEnv As String
Dim LastToken As String
'Set and Instantiate our working objects
Set objHTTP = New MSXML2.XMLHTTP
sURL = "https://www.dhltoolboxtest.se/DHLTimeTableWS/TimeTable.asmx"
'SOAP envelope for submission to the Web Service
sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
sEnv = sEnv & "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"
xmlns: ns1 = "http://dhltimetable.dhl.com/" > ""
sEnv = sEnv & " <SOAP-ENV:Header/>"
sEnv = sEnv & " <SOAP-ENV:Body>"
sEnv = sEnv & " <ns1:GetTimeTable>"
sEnv = sEnv & " <ns1:strUser>TimeTableAppUser</ns1:strUser>"
sEnv = sEnv & " <ns1:strPwd>TTA%Pwd06</ns1:strPwd>"
sEnv = sEnv & " <ns1:intType>1</ns1:intType>"
sEnv = sEnv & " <ns1:strCountryCode>SE</ns1:strCountryCode>"
sEnv = sEnv & " <ns1:strPickupPostCode>44361</ns1:strPickupPostCode>"
sEnv = sEnv & " <ns1:strPickupPlace>Stenkullen</ns1:strPickupPlace>"
sEnv = sEnv & " <ns1:strDeliveryCountryCode>SE</ns1:strDeliveryCountryCode>"
sEnv = sEnv & " <ns1:strDeliveryPostCode>50189</ns1:strDeliveryPostCode>"
sEnv = sEnv & " <ns1:strDeliveryPlace>BORÅS</ns1:strDeliveryPlace>"
sEnv = sEnv & " <ns1:blnEarliestSent>true</ns1:blnEarliestSent>"
sEnv = sEnv & " <ns1:dtDate>2016-02-25</ns1:dtDate>"
sEnv = sEnv & " <ns1:blnHolidayCheck>true</ns1:blnHolidayCheck>"
sEnv = sEnv & " </ns1:GetTimeTable>"
sEnv = sEnv & " </SOAP-ENV:Body>"
sEnv = sEnv & "</SOAP-ENV:Envelope>"
'invoke the web service
objHTTP.Open "Post", sURL, False
objHTTP.setRequestHeader "Content-Type", "text/xml"
objHTTP.send (sEnv)
MsgBox objHTTP.responseText
End Sub
 
Upvote 0
Try using late binding rather then early binding.

That is;

Remove the following line:
Code:
Set objHTTP = New MSXML2.XMLHTTP

Place the following line instead of the above removed line:
Code:
Set objHTTP = CreateObject("MSXML2.XMLHTTP")

and run the code again to see whats going on.

Also, make sure to supply all the string data needed to send a correct POST to the server. Such as; user, password, URL, country code ......
 
Last edited:
Upvote 0
Yeah, that cut&paste did not come out correct.... Thanks again, now I do not get any error messages, but where/how should I expect the response from?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top