SOAP Call through VBA

Duckmorph

New Member
Joined
Aug 2, 2013
Messages
25
Hey

Im want to be able to use SOAP calls to call a server and get the information to an excel cell. I have been trying to figure it out via other threads but im stilll just as lost can anyone help with this. Im sure if i can get one working all other requests should be easy.

This is the information provided from the TAB is

'Target
https://api.tab.com.au/tabapi/services/thirdPartyAuthenticate
'Example SOAP Request
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.thirdparty.api.neo.tabcorp.com.au/">
<soapenv:header>
<soapenv:body>
<ser:authenticateaccount>
<apimeta>
<jurisdictionid>1</jurisdictionid>
<requestchannel>5</requestchannel>
<usernamepasswordtoken></usernamepasswordtoken>
</apimeta>
<authrequest>
<accountid>ACCOUNT ID GOES HERE</accountid>
<accountpassword>PASSWORD GOES HERE</accountpassword>
</authrequest>
</ser:authenticateaccount>
</soapenv:body>
</soapenv:header></soapenv:envelope>
My very poor attempt is

Sub TABcall()
Dim xmlHtp As New MSXML2.XMLHTTP
Dim sURL As String
Dim sEnv As String
Dim XMLDOC As New DOMDocument
sURL = "https://api.tab.com.au/tabapi/services/thirdPartyAuthenticate"

sEnv = <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.thirdparty.api.neo.tabcorp.com.au/">"
sEnv = sEnv & "<soapenv:header>"
sEnv = sEnv & " <soapenv:body>"
sEnv = sEnv & " <ser:authenticateaccount>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <apimeta>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <jurisdictionid>1</jurisdictionid>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <requestchannel>5</requestchannel>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " </apimeta>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <authrequest>"
sEnv = sEnv & " <accountid>1212124</accountid>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <accountpassword>password</accountpassword>"
sEnv = sEnv & " </authrequest>"
sEnv = sEnv & " </ser:authenticateaccount>"
sEnv = sEnv & " </soapenv:body>"
sEnv = sEnv & "</soapenv:header></soapenv:envelope>"

With xmlHtp
.Open "POST", sURL, False
.setRequestHeader "Host", ""
.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
.setRequestHeader "soapAction", "QueryCSV" ' per the documentation
.send sEnv
XMLDOC.LoadXML .responseText
XMLDOC.Save ActiveWorkbook.Path & "\WebQueryResult2.xml"
End With


MsgBox xmlHtp.statusText

End Sub

Can anyone help with this?
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hey

Im want to be able to use SOAP calls to call a server and get the information to an excel cell. I have been trying to figure it out via other threads but im stilll just as lost can anyone help with this. Im sure if i can get one working all other requests should be easy.

This is the information provided from the TAB is

'Target
https://api.tab.com.au/tabapi/services/thirdPartyAuthenticate
'Example SOAP Request
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.thirdparty.api.neo.tabcorp.com.au/">
<soapenv:header>
<soapenv:body>
<ser:authenticateaccount>
<apimeta>
<jurisdictionid>1</jurisdictionid>
<requestchannel>5</requestchannel>
<usernamepasswordtoken></usernamepasswordtoken>
</apimeta>
<authrequest>
<accountid>ACCOUNT ID GOES HERE</accountid>
<accountpassword>PASSWORD GOES HERE</accountpassword>
</authrequest>
</ser:authenticateaccount>
</soapenv:body>
</soapenv:header></soapenv:envelope>
My very poor attempt is

Sub TABcall()
Dim xmlHtp As New MSXML2.XMLHTTP
Dim sURL As String
Dim sEnv As String
Dim XMLDOC As New DOMDocument
sURL = "https://api.tab.com.au/tabapi/services/thirdPartyAuthenticate"

sEnv = <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.thirdparty.api.neo.tabcorp.com.au/">"
sEnv = sEnv & "<soapenv:header>"
sEnv = sEnv & " <soapenv:body>"
sEnv = sEnv & " <ser:authenticateaccount>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <apimeta>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <jurisdictionid>1</jurisdictionid>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <requestchannel>5</requestchannel>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " </apimeta>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <authrequest>"
sEnv = sEnv & " <accountid>1212124</accountid>"
sEnv = sEnv & " <!--Optional:-->"
sEnv = sEnv & " <accountpassword>password</accountpassword>"
sEnv = sEnv & " </authrequest>"
sEnv = sEnv & " </ser:authenticateaccount>"
sEnv = sEnv & " </soapenv:body>"
sEnv = sEnv & "</soapenv:header></soapenv:envelope>"

With xmlHtp
.Open "POST", sURL, False
.setRequestHeader "Host", ""
.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
.setRequestHeader "soapAction", "QueryCSV" ' per the documentation
.send sEnv
XMLDOC.LoadXML .responseText
XMLDOC.Save ActiveWorkbook.Path & "\WebQueryResult2.xml"
End With


MsgBox xmlHtp.statusText

End Sub

Can anyone help with this?[/QUOTE]
 
Upvote 0
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.thirdparty.api.neo.tabcorp.com.au/">
<soapenv:Header/>
<soapenv:Body>
<ser:authenticateAccount>
<apiMeta>
<jurisdictionId>1</jurisdictionId>
<requestChannel>5</requestChannel>
<usernamePasswordToken></usernamePasswordToken>
</apiMeta>
<authRequest>
<accountId>ACCOUNT ID GOES HERE</accountId>
<accountPassword>PASSWORD GOES HERE</accountPassword>
</authRequest>
</ser:authenticateAccount>
</soapenv:Body>
</soapenv:Envelope>
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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