getCodeFromCountryName 

 

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 System;
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";

      // Set up a web service object
      validate.validate wsObject = new validate.validate();

      // make the call to the Validate getCodeFromCountryName method
      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 .

 Visual Basic.net Example 1

  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 - validateBic
  anObject = wsobject.getCodeFromCountryName("qwerty", "United Kingdom")

 

Visual Basic.net Example 2

Module Module1
  Sub Main()

    ' define the keycode and bic to validate, both as strings.
    Dim keycode As String = "qwerty"
    Dim countryName As String = "United Kingdom"

    ' Create a web service object
    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 {
 
    public static void main(String[] args) {

        validate.Validate service = new validate.Validate();
        validate.ValidateSoap port = service.getValidateSoap12();

        java.lang.String keyCode = "qwerty" ;
        java.lang.String countryName  = "United Kingdom" ;

        validate.CountryNames result = port.getCodeFromCountryName(keyCode,  countryName);
        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"?>
<
soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://vtest.bemac.com/">
  <soap:Body>
    <tns:getCodeFromCountryName>
      <tns:keyCode>qwerty</tns:keyCode>
      <tns:countryCode>United Kingdom</tns:countryCode>
    </tns:getCodeFromCountryName>
  </soap:Body>
</
soap:Envelope>

 

Below is a typical XML message response

<?xml version="1.0" encoding="utf-8"?>
<
soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <getCodeFromCountryNameResponse xmlns="http://vtest.bemac.com/">
      <getCodeFromCountryNameResult>
        <isoCountryName>United Kingdom</isoCountryName>
        <isoCountryFullName>United Kingdom of Great Britain &amp; N. Ireland</isoCountryFullName>
        <isoCountryCode>GB</isoCountryCode>
        <threeCode>PYF</threeCode>
        <numberCode>258</numberCode>
        <errorCode />
        <errorText />
      </getCodeFromCountryNameResult>
    </getCodeFromCountryNameResponse>
  </soap:Body>
</
soap:Envelope>