This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Search in Postcodelookup
The postCodeLookUp
operation searches postcode or address fragment retrieves details about the postcode or address fragment.
postCodeLookUp
<postcodelookup.postcodelookup configKey="MyPostCodeConfig"> <searchTerm>{$ctx:searchTerm}</searchTerm> <responseType>{$ctx:responseType}</responseType> <lines>{$ctx:lines}</lines> <include>{$ctx:include}</include> <exclude>{$ctx:exclude}</exclude> <format>{$ctx:format}</format> <addtags>{$ctx:addtags}</addtags> <identifier>{$ctx:identifier}</identifier> <callback>{$ctx:callback}</callback> <page>{$ctx:page}</page> <postcodeonly>{$ctx:postcodeonly}</postcodeonly> </postcodelookup.postcodelookup>
Properties
searchTerm
: Required - The term being searched for, can be postcode or address fragment being searched for.responseType
: The number of search results to return per page.lines:
The number of lines over which to split each address.include
: Include extra address fields within the address lines returned.exclude
: Exclude address fields within the address lines returned.format
: xml | json (default unless header of application/xml is detected).addtags
: Add extra address fields to the return.identifier
: Identify your lookups to make debugging and reviewing stats easier.callback
: Use to specify the name of your JSONP callback function.page
: For use with searches that return more than 100 results (first page is 0).postcodeonly
: Use ?postcodeonly=true to limit your search to just the postcode field.
Sample request
Following is a sample REST/JSON request that can be handled by the postCodeLookUp operation.
Sample Request for postCodeLookUp
{ "searchTerm":"NR147PZ", "responseType":"json", "lines":"3", "postcodeonly":"true" }
Related postCodeLookUp documentation
https://developers.alliescomputing.com/postcoder%C2%ADweb%C2%ADapi/address%C2%ADlookup/premise
Sample configuration
Following is a sample proxy service that illustrates how to connect to postCodeLookUp with the init
operation and use the completeContext operation. The sample request for this proxy can be found in postCodeLookUp sample request.
Sample Proxy
<?xmlversion="1.0"encoding="UTF-8"?> <proxyxmlns="http://ws.apache.org/ns/synapse" name="postcodelookup" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <propertyexpression="json-eval($.apiKey)"name="apiKey" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.apiUrl)"name="apiUrl" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.searchTerm)"name="searchTerm" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.responseType)"name="responseType" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.lines)"name="lines" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.include)"name="include" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.exclude)"name="exclude" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.format)"name="format" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.addtags)"name="addtags" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.identifier)"name="identifier" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.callback)"name="callback" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.page)"name="page" xmlns:ns="http://org.apache.synapse/xsd"/> <propertyexpression="json-eval($.postcodeonly)"name="postcodeonly" xmlns:ns="http://org.apache.synapse/xsd"/> <postcodelookup.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <apiKey>{$ctx:apiKey}</apiKey> </postcodelookup.init> <postcodelookup.postcodelookup> <searchTerm>{$ctx:searchTerm}</searchTerm> <responseType>{$ctx:responseType}</responseType> <lines>{$ctx:lines}</lines> <include>{$ctx:include}</include> <exclude>{$ctx:exclude}</exclude> <format>{$ctx:format}</format> <addtags>{$ctx:addtags}</addtags> <identifier>{$ctx:identifier}</identifier> <callback>{$ctx:callback}</callback> <page>{$ctx:page}</page> <postcodeonly>{$ctx:postcodeonly}</postcodeonly> </postcodelookup.postcodelookup> <respond/> </inSequence> <outSequence> <send/> </outSequence> </target> <description/> </proxy>