Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/WebServices/TIN Check
Function:
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/WebServices/TIN Check
This example is the version from Wed, 10th Nov 2015.
Project "TIN Check.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Const XMLTemplate = "<?xml version=""1.0"" encoding=""UTF-8""?><SOAP:Envelope xmlns:SOAP=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:ENC=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:si=""http://soapinterop.org/xsd""><SOAP:Body><ns1:checkTin xmlns:ns1=""urn:ec.europa.eu:taxud:tin:services:checkTin:types""><ns1:countryCode xsi:type=""xsd:string"">$country$</ns1:countryCode><ns1:tinNumber xsi:type=""xsd:string"">$number$</ns1:tinNumber></ns1:checkTin></SOAP:Body></SOAP:Envelope>"
Control CheckButton Inherits PushButton
ControlInstance CheckButton Inherits PushButton
EventHandler Sub Action() dim c as new CURLSMBS dim xml as string = XMLTemplate xml = Replace(xml, "$country$", TextField1.text) xml = Replace(xml, "$number$", TextField2.text) List.AddRow "Check "+TextField2.text+"..." c.OptionFollowLocation = true c.OptionMaxRedirs = 3 c.OptionPostFields = xml c.OptionUserAgent = "MBS TIN Check 1.0" c.OptionURL = "https://ec.europa.eu/taxation_customs/tin/services/checkTinService" c.OptionPost = true c.SetOptionHTTPHeader array("Content-Type: application/soap+xml; charset=utf-8") dim e as integer = c.Perform dim debugMessage as string = c.DebugData dim Result as STring = c.OutputData if e = 0 then dim r as integer = c.GetInfoResponseCode if r = 200 then // ok dim doc as new XmlDocument(result) dim envelope as XmlNode = FindChild(doc, "envelope") dim body as XmlNode = FindChild(envelope, "body") dim checkTinResponse as XmlNode = FindChild(body, "checkTinResponse") dim x as XmlNode = checkTinResponse.FirstChild while x <> nil dim key as string = x.Name dim value as string = getText(x) List.AddRow key+": "+value x = x.NextSibling wend else List.AddRow "HTTP error: "+str(r) end if else List.AddRow "CURL error: "+str(e)+" "+c.LasterrorMessage end if List.ScrollPosition = List.ListCount End EventHandler
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control TextField2 Inherits TextField
ControlInstance TextField2 Inherits TextField
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Function FindChild(n as xmlnode, name as string) As XmlNode n = n.FirstChild while n <> nil if n.LocalName = name then Return n end if n = n.NextSibling wend End Function
Function getText(x as XmlNode) As string dim r as XmlNode = x.FirstChild dim parts() as string while r <> nil if r isa XmlTextNode then parts.Append r.Value end if r = r.NextSibling wend Return Join(parts, "") End Function
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
End Project

The items on this page are in the following plugins: MBS CURL Plugin.

Feedback: Report problem or ask question.

The biggest plugin in space...


Start Chat