Derives the ISO3166 country code from a country name.
Syntax:
getCodeFromCountryName
(string keycode, string country name)
Returned
data
An object array countryNames containing the following fields:
Object
Explanation
isoCountryName
The ISO3166 English short name of a country
(e.g. United Kingdom)
isoCountryFullName
The ISO3166 English full name of a country
(e.g. United Kingdom of Great Britain & N. Ireland)
isoCountryCode
The ISO 3166-1-alpha-2 code representing a country
(e.g. GB, FR, etc.)
threeCode
The ISO3166 three character country code for a
country (E.g. GBR)
numberCode
The ISO 3166 number code for a country. (E.g.
826)
errorCode
If an
error occurs during processing the error number will be here. See
the error section for more details.
errorText
If an error occurs
during processing the error textually description will be here. See the
error section for more details.
Supported Versions
Validate Web Service Version 1.x
Errors
1902 Country Not found
Example
Code
c#
The following sample show how to use the getCodeFromCountryName function using
c#.
As with all
examples, please see the section Adding a reference to
the Validate Web Service .
c# Example 1 validate.validate wsObject = new validate.validate();
validate.countryNames cname =
wsObject.getCodeFromCountryName(keycode,
countryName);
c# Example 2 using // Set up a web
service object
using
System.Collections.Generic;
using System.Text;
namespace
getCodeFromCountryName
{
class Program
{
static void Main(string[] args)
{
// Define strings for the keycode and the country name
string keycode = "qwerty";
string countryName = "United Kingdom";
validate.validate
wsObject = new
validate.validate();
validate.countryNames cname =
wsObject.getCodeFromCountryName(keycode, countryName);
// now we have an
object 'cname' containing our details
Console.WriteLine("The ISO Country Code for " + countryName
+" is "+ cname.isoCountryCode);
Console.WriteLine(cname.errorCode);
Console.WriteLine(cname.errorText);
Console.ReadLine();
}
}
}
Visual Basic .net
The following sample show how to use the getCodeFromCountryName function
using Visual Basic.net.
As wilth all examples, please see the section Adding a reference to the Validate Web
Service .
Dim wsobject As New validate.validate()
Visual Basic.net Example 1
' create a account number object for the returning
data
Dim
anObject As validate.countryNames
' Call the web service function -
validateBic
anObject =
wsobject.getCodeFromCountryName("qwerty", "United Kingdom")
Visual Basic.net
Example 2 Module Module1Sub Main() ' define the keycode and
bic to validate, both as strings. Dim wsobject As New validate.validate() ' create a account number object for the returning data Dim anObject As validate.countryNames ' Call the web service function anObject = wsobject.getCodeFromCountryName(keycode, countryName) ' display the results Console.WriteLine(anObject.isoCountryCode) Console.WriteLine(anObject.errorCode) Console.WriteLine(anObject.errorText) Console.ReadLine() End Sub End Module |
Java
The following sample show
how to use the getCodeFromCountryName using Java.
Java Example
1 package getcodefromcountryname; public
class Main {
validate.Validate service = new
validate.Validate(); java.lang.String
keyCode = "qwerty"
;
validate.CountryNames result = port.getCodeFromCountryName(keyCode,
countryName); }
public static void main(String[] args)
{
validate.ValidateSoap port =
service.getValidateSoap12();
java.lang.String
countryName = "United Kingdom"
;
System.out.println( "The ISO Country
Code for " + countryName+ " is "+
result.getIsoCountryCode());
System.out.println( "Error
Code = "
+result.getErrorCode());
System.out.println( "Error
Message = " +result.getErrorText());
}
XML Messages
Below is a typical XML message request
<?
xml version="1.0" encoding="utf-8"?>Below is a typical XML message response
<?
xml version="1.0" encoding="utf-8"?>