You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/VAT ID Check/VATCheck
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Const XMLVorlage = "<?xml version=""1.0"" encoding=""UTF-8""?>\n<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/"">\n <env:Body>\n <checkVat xmlns=""urn:ec.europa.eu:taxud:vies:services:checkVat:types"">\n <countryCode>%1</countryCode>\n <vatNumber>%2</vatNumber>\n </checkVat>\n </env:Body>\n</env:Envelope>\n\n\n"
Control Country Inherits TextField
ControlInstance Country Inherits TextField
End Control
Control IDNo Inherits TextField
ControlInstance IDNo Inherits TextField
End Control
Control CountryLabel Inherits Label
ControlInstance CountryLabel Inherits Label
End Control
Control IDNoLabel Inherits Label
ControlInstance IDNoLabel Inherits Label
End Control
Control AbfrageButton Inherits PushButton
ControlInstance AbfrageButton Inherits PushButton
EventHandler Sub Action()
dim url as string = "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
dim xml as string = XMLVorlage
xml = Replace(xml, "%1", country.Text)
xml = Replace(xml, "%2", idno.Text)
socke.SetRequestContent xml, "text/xml; charset=utf-8"
socke.Post url
End EventHandler
End Control
Control Socke Inherits HTTPSocket
ControlInstance Socke Inherits HTTPSocket
EventHandler Sub Connected()
List.AddRow CurrentMethodName
End EventHandler
EventHandler Sub Error(code as integer)
List.AddRow CurrentMethodName+" "+stR(code)
End EventHandler
EventHandler Sub PageReceived(url as string, httpStatus as integer, headers as internetHeaders, content as string)
List.AddRow CurrentMethodName
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
'<soap:Body>
'<checkVatResponse xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
'<countryCode>DE
'</countryCode>
'<vatNumber>182723467
'</vatNumber>
'<requestDate>2014-07-18+02:00
'</requestDate>
'<valid>true
'</valid>
'<name>---
'</name>
'<address>---
'</address>
'</checkVatResponse>
'</soap:Body>
'</soap:Envelope>
if content.Encoding = nil then
content = DefineEncoding(content, encodings.UTF8)
end if
if httpStatus = 200 then
// you could parse XML here or simply check if right tag is there:
Dim doc As New XmlDocument(content)
Dim EnvelopeNode As XmlNode = doc.FirstChild
Dim BodyNode As XmlNode = FindNode(EnvelopeNode, "Body")
Dim checkVatResponseNode As XmlNode = FindNode(BodyNode, "checkVatResponse")
Dim validNode As XmlNode = FindNode(checkVatResponseNode, "valid")
Dim nameNode As XmlNode = FindNode(checkVatResponseNode, "name")
Dim valid As String = validNode.FirstChild.Value
If valid = "true" Then
MsgBox "OK: "+nameNode.FirstChild.Value
else
MsgBox "Not OK"
end if
else
List.AddRow "HTTP Status: "+str(httpStatus)
end if
End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Function FindNode(n as XmlNode, name as string) As XmlNode
Dim p As XmlNode = n.FirstChild
While p <> Nil
If p.LocalName = name Then
Return p
End If
p = p.NextSibling
Wend
End Function
Note "Note"
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar