How to Consume Service (Example Code):

[PHP Code]

1. Using CURL (PHP 4 >= 4.0.2, PHP 5)

$service_url = "http://services.boldsystems.org/eFetch.php?id_type=sequenceid&ids=(1)&record_type=full&return_type=xml";
$contents = getContentsFromUrl($service_url);
if ($contents){
   echo $contents;
}

function getContentsFromUrl($url){
   $c = curl_init($url);
   curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); //to follow the redeirects
   $result = curl_exec($c);
   curl_close($c);
   return $result; 
}

2. Using File methods (PHP 4 >= 4.0.2, PHP 5)

$service_url = "http://services.boldsystems.org/eFetch.php?id_type=sequenceid&ids=(1)&record_type=full&return_type=xml&file_type=zip";
$contents = getContentsFromUrl($service_url);
if ($contents){
   writeFile($path,$contents);
}

function getContentsFromUrl($url){
   $content = file_get_contents($url);
   if ($content != false)
       return $content;
   else if (!isset($http_response_header))
       return null;    // Bad url, timeout
}

function writeFile($file,$datastr) {
   $handle=fopen($file,'w');
   $ret=fwrite($handle,$datastr."\n");
   fclose($handle);
   if (!$ret) return false;
     else return true; 
}

[Java Code]

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

public class BoldService {
    
    public BoldService() {
    }
    
    public static void main(String[] args) {
        String serviceUrl = "http://services.boldsystems.org/eFetch.php?id_type=sequenceid&ids=(1)&record_type=full&return_type=xml";
        URL url = null;
        String inputLine = null;

		try {
            url = new URL(serviceUrl);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            
            while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);
            
            in.close();
            
        } catch (MalformedURLException ex) {
            ex.printStackTrace();
        } catch(IOException ioe){
            ioe.printStackTrace();
        }
    }
}