1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| Sub API_CALL()
Dim sURL As String
Dim sEnv As String
Dim xmlDoc As New DOMDocument
Dim sEnvlength As Integer
Dim responseText As String
Dim MyString As String
Dim LastRow As Long
MyString = "GetClaimStatus"
Set ObjHttp = New MSXML2.XMLHttp
sURL = "http://*ADDRESSE API*/Api/v2/***.asmx"
sEnv = sEnv & "<?xml version=""1.0"" encoding=""utf-8""?>"
sEnv = sEnv & "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:wsa=""http://schemas.xmlsoap.org/ws/2004/08/addressing"" xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"" xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">"
sEnv = sEnv & " <soap:Header>"
sEnv = sEnv & " <AuthenticationHeader AccountNumber=""USERNAME"" Password=""PASSWORD"" xmlns=""http://*ADDRESSE API*/webservices/"" />"
sEnv = sEnv & " <wsa:Action>http://*ADDRESSE API*/webservices/GetClaimStatus</wsa:Action>"
sEnv = sEnv & " <wsa:MessageID>urn:uuid:5e261edc-603f-46dc-8d62-a39ad3986f26</wsa:MessageID>"
sEnv = sEnv & " <wsa:ReplyTo>"
sEnv = sEnv & " <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>"
sEnv = sEnv & " </wsa:ReplyTo>"
sEnv = sEnv & " <wsa:To>http://*ADDRESSE API*/Api/v2/***.asmx</wsa:To>"
sEnv = sEnv & " <wsse:Security>"
sEnv = sEnv & " <wsu:Timestamp wsu:Id=""Timestamp"">"
sEnv = sEnv & " <wsu:Created>" & Format(Now(), "yyyy-MM-dd") & "T" & Format(Now() + TimeSerial(5, 0, 0), "hh:mm:ss") & "Z</wsu:Created>" '+ TimeSerial(5, 0, 0) means + 5 hours, because Test is + 5 hours with Montreal
sEnv = sEnv & " <wsu:Expires>" & Format(Now(), "yyyy-MM-dd") & "T" & Format(Now() + TimeSerial(5, 0, 0) + TimeSerial(0, 5, 0), "hh:mm:ss") & "Z</wsu:Expires>"
sEnv = sEnv & " </wsu:Timestamp>"
sEnv = sEnv & " </wsse:Security>"
sEnv = sEnv & " </soap:Header>"
sEnv = sEnv & " <soap:Body>"
sEnv = sEnv & " <GetClaimStatus xmlns=""http://*ADDRESSE API*/webservices/"">"
sEnv = sEnv & " <claimIDSpecification ClaimID=""22_02_2016_01"" ClaimIDType=""ClaimNumber"" />"
sEnv = sEnv & " <companyIDSpecification CompanyID=""049-246-601"" CompanyIDType=""CompanyID"" />"
sEnv = sEnv & " </GetClaimStatus>"
sEnv = sEnv & " </soap:Body>"
sEnv = sEnv & "</soap:Envelope>"
sEnvlength = Len(sEnv)
ObjHttp.Open "POST", sURL, False
ObjHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
ObjHttp.setRequestHeader "Content-Length", sEnvlength
ObjHttp.send (sEnv)
xmlDoc.LoadXML (ObjHttp.responseText)
Cells(1, 1) = ObjHttp.responseText
responseText = xmlDoc.SelectNodes("//claimStatus")(0).Text 'on next i (=2) I got Error '91' - object variable or With block variable not set
MsgBox responseText
sEnv = ""
Set xmlDoc = Nothing
Set ObjHttp = Nothing
End Sub |
Partager