Tip -> Postcode/huisnummer: gratis adrescheck via webservice

denpar
Member Posts: 80
De website Postcodes.nl (https://www.postcodes.nl) heeft een gratis webservice (maximaal 100 verzoeken per dag) waarmee op basis van een postcode (6 karakters) en een huisnummer de bijbehorende straat- en plaatsnaam gevonden kan worden.
Variables
Variables
Name DataType Subtype Length abpDotXml DotNet 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument abpDotXmlnodelist DotNet 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList abpIntCount Integer abpDotXmlnode DotNet 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode abpTxtApiKey Text 100
abpFncGetStreetnameCity(parPostcode : Code[10];parHouseNo : Code[10]) IF (parPostcode = '') OR (parHouseNo = '') THEN EXIT; parPostcode := DELCHR(parPostcode,'=',' '); IF STRLEN(parPostcode) <> 6 THEN EXIT; abpTxtApiKey := 'beschikbaar na het aanmaken van een account'; abpDotXml := abpDotXml.XmlDocument(); abpDotXml.Load('http://api.postcodes.nl/1.0/address/?apikey='+abpTxtApiKey+'&nlzip6='+parPostcode+'&streetnumber='+parHouseNo+ '&output=xml'); abpDotXmlnodelist := abpDotXml.SelectNodes('//*'); IF (abpDotXmlnodelist.ToString() <> '') THEN BEGIN FOR abpIntCount := 0 TO abpDotXmlnodelist.Count - 1 DO BEGIN abpDotXmlnode := abpDotXmlnodelist.Item(abpIntCount); CASE abpDotXmlnode.Name OF 'status' : BEGIN IF abpDotXmlnode.InnerText='error' THEN ERROR('Combinatie postcode/huisnummer niet gevonden!'); END; 'streetname': Address := COPYSTR(abpDotXmlnode.InnerText,1,50); 'city' : City := UPPERCASE(COPYSTR(abpDotXmlnode.InnerText,1,30)); END END; END;
If your work becomes a passion...
www.pardaan.com
www.pardaan.com
0
Comments
-
Bedankt
Bij deze dan een wijziging voor de classic client.
In codeunit 11401: Post Code Management, functie FindStreetName, wijzig de code //NA naar://NA CASE TRUE OF //NA CountryCode <> '': EXIT; //NA NewAddress = '': EXIT; //NA NOT ParseAddress(NewAddress, NewHouseNo, NewPostCode): EXIT; //NA END; //NA //NA IF NOT PostCodeLookupTable.FindStreetNameFromAddress( //NA NewStreetname, NewHouseNo, NewPostCode, NewCity, NewPhoneNo, NewFaxNo) THEN //NA EXIT; //MOD:> CASE TRUE OF ((CountryCode <> '') AND (CountryCode <> 'NL')): EXIT; NewAddress = '': EXIT; NOT ParseAddress(NewAddress, NewHouseNo, NewPostCode): EXIT; END; IF NOT PostCodeLookupTable.FindStreetNameFromAddress( NewStreetname, NewHouseNo, NewPostCode, NewCity, NewPhoneNo, NewFaxNo) THEN IF NOT FindOnline( NewStreetname, NewHouseNo, NewPostCode, NewCity, NewPhoneNo, NewFaxNo) THEN EXIT; //MOD:<
Voeg deze functie toe:PROCEDURE FindOnline@1000000000(VAR vPtStreetName@1000005 : Text[50];VAR vPtHouseNo@1000004 : Text[50];VAR vPcPostCode@1000003 : Code[20];VAR vPtCity@1000002 : Text[50];VAR vPtPhoneNo@1000001 : Text[30];VAR vPtFaxNo@1000000 : Text[30]) : Boolean; VAR LaWinHttp@1000000002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{88D96A0A-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v6.0'.XMLHTTP60"; LtValue@1000000000 : Text[250]; LtUrl@1000000003 : Text[260]; LaXmlDoc@1000000004 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{88D96A05-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v6.0'.DOMDocument60"; LaXmlNode@1000000005 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; LbFound@1000000006 : Boolean; LtcAskToGoOnline@1000000001 : TextConst 'ENU=Get Address and City?;NLD=Adres en Plaats ophalen?'; LtApiKey@1000000007 : Text[100]; BEGIN IF (DELCHR(vPcPostCode, '=') = '') THEN BEGIN EXIT(FALSE); END; IF (DELCHR(vPtHouseNo, '=') = '') THEN BEGIN EXIT(FALSE); END; IF (NOT GUIALLOWED) THEN BEGIN EXIT(FALSE); END; IF NOT CONFIRM(LtcAskToGoOnline, TRUE) THEN BEGIN EXIT(FALSE); END; LbFound := FALSE; LtApiKey := 'YOUR OWN APIKEY'; CREATE(LaWinHttp); CREATE(LaXmlDoc); LtUrl := STRSUBSTNO('http://api.postcodes.nl/1.0/address/?apikey=%1&nlzip6=%2&streetnumber=%3&output=xml', LtApiKey, DELCHR(vPcPostCode, '='), DELCHR(vPtHouseNo, '=')); LaWinHttp.open('GET', LtUrl, FALSE); LaWinHttp.send(); IF (LaWinHttp.status = 200) AND (UPPERCASE(LaWinHttp.statusText) = 'OK') THEN BEGIN LaXmlDoc.load(LaWinHttp.responseBody); IF NOT ISCLEAR(LaXmlDoc) THEN BEGIN LaXmlNode := LaXmlDoc.selectSingleNode('/response/errormessage'); IF NOT ISCLEAR(LaXmlNode) THEN BEGIN LtValue := COPYSTR(LaXmlNode.text, 1, 250); MESSAGE('Errormessage: %1, Url: %2', LtValue, LtUrl); END ELSE BEGIN LaXmlNode := LaXmlDoc.selectSingleNode('/response/results/result/streetname'); IF NOT ISCLEAR(LaXmlNode) THEN BEGIN LtValue := COPYSTR(LaXmlNode.text, 1, 50); vPtStreetName := STRSUBSTNO('%1', LtValue); LbFound := TRUE; END; LaXmlNode := LaXmlDoc.selectSingleNode('/response/results/result/city'); IF NOT ISCLEAR(LaXmlNode) THEN BEGIN LtValue := COPYSTR(LaXmlNode.text, 1, 50); vPtCity := STRSUBSTNO('%1', LtValue); LbFound := TRUE; END; END; //LaXmlDoc.save('D:\Postcode.xml'); END; END ELSE BEGIN MESSAGE('Error: %1, Url: %2', LaWinHttp.status, LtUrl); END; CLEAR(LaWinHttp); CLEAR(LaXmlDoc); EXIT(LbFound); END; BEGIN END. }
Wijzig de regel:
'YOUR OWN APIKEY' naar '04b91b7b6c721ba8d41a403dc90ea992adafb44d25e5b8d3134e18567b725541'
Bijvoorbeeld bij een contactpersoon:
Vul in het adresveld in de tekst: 2909LK22
en je krijgt: "Rivium Boulevard 22, Capelle aan den IJssel"0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions