Chapter 1. IMPORTANT ISSUES

Table of Contents

Considerations
Available Tools and Demos
References

version: 0.18

Considerations

Server address: http://backend.antagus.de

All requests described afterwards are relative to this address

BDOM system works over an Apache server and the xmlApi requests are encapsulated in HTTP messages.

For more information on HTTP protocol see RFC

Authentication for xmlApi requests is based on IP - USER_ID pairs.

USER_ID is a number assigned by BDOM system when your account has been created, ex. 22

In to order accept your requests please send your public IP address to domains@antagus.de

[Warning]Warning

At this moment, the name and number of some fields in both the requests and answers are subject to change.

All the differences from one version to another will be found on the Changes page

Available Tools and Demos

Demo in PHP to connect to BDOM server over HTTP:

Example 1.1. PHP Demo

      
#!/usr/local/bin/php -q
<?
class httpRequest {
      var $host;
      var $port;

      //constructor
      function httpRequest($host,$port){
	$this->host = $host;
	$this->port = $port;
      }

      //uri to get
      function get($uri) {
	return $this->request('GET',$uri,'');
      }

      //uri to put body(xml)
      function put($uri,$body) {
	return $this->request('PUT',$uri,$body);
      }

      //uri to post body(xml)
      function post($uri,$body) {
	return $this->request('POST',$uri,$body);
      }

      //uri to delete
      function delete($uri) {
	return $this->request('DELETE',$uri,'');
      }
      
      // private methods 
      //make request to server
      function request($method, $uri, $body){
	//open socket
	$sd = fsockopen($this->host, $this->port, $errno,$errstr);
	if (!$sd) {
	  $result = "Error: connection failed";
	}else{
	  //send request to server
	  fputs($sd,$this->make_string($method, $uri, $body));

	  //read answer
	  $nl = 0;//new line detector

	  //initialize body length on a high value
	  $count = 65535;
	  while ($str = fgets($sd, 1024)){
	    $result .= $str;
	    $count = $count - strlen($str);
	    if ($nl == 1) {
	      //set count to actual body length
	      $count = hexdec($str);
	      $nl = 0;
	    }

	    //remove CR/LF
	    $str = preg_replace('/\015\012/', '',$str);
	    if ($str == '') {
	      $nl = 1;
	    }
	    if ($count <= 0) {
	      break;
	    }
	  }
	}

	//close socket
	if($sd) {
	  fclose($sd);
	}

	$this->response = $result;
	return $result;
      }

      //create request
      function make_string($method, $uri, $body){
	  //header: method + host
	  $str = strtoupper($method)." ".$uri." HTTP/1.1\nHOST: ".$this->host;

	  //header: ...
	  $str .= "\nConnection: Keep-Alive\nUser-Agent: bdomHTTP\nContent-Type: text/xml; charset=iso-8859-1";

	  //header: body size ... if any
	  if ($body) {
	    $str .= "\nContent-Length: ".strlen($body);
	  }

	  $str .= "\n\n";

	  //append body ... if any
	  if ($body) {
	    $str .= $body ;
	  }
	  return $str;
      }

}

class httpResponse {
  var $resp;

  function httpResponse($resp) {
    $this->resp = $resp;
  }

  //extract response code
  function code() {
    preg_match('/HTTP\/[10\.]+\s+([0-9]+)/', $this->resp, $code);
    return $code[1];
  }
  
  //extract response body
  function body() {
    //body is between two empty lines for "chunked" encoding
    $chunk = preg_split('/(?=^\r)/m',$this->resp);
    $body = "";
    if ($chunk[1]){
      //extract body from \nsize(body)\n0
      $body = ereg_replace("\n[0-9a-fA-F]+", "", $chunk[1]);
    }

    return trim($body);
  }
}

$obj = new httpRequest("backend.antagus.de",80);
$uri = "/bdom/contact/status/NIRAA0002/19/";

print "Unparsed response:\n";
print $obj->get($uri);

$resp = new httpResponse($obj->get($uri));
print "Response Code: ".$resp->code()."\n";
print "Response Body:\n";
print $resp->body()."\n";
?>
      
      

Demo in RUBY to connect to BDOM server over HTTP:

Example 1.2. RUBY Demo:

      
#!/usr/local/bin/ruby
require 'net/http'
class BdomReq
  Def initialize(server, port)
    @server = server
    @port = port 
  end

  def get(path)
    begin
      h = Net::HTTP.new(@server, @port)
      @resp,@data=h.get(path, nil)
      puts @resp.code.to_s
      return @data
    rescue  SocketError => err
      puts "socket error"+err.to_s
    end
  end

  def delete(path)
    begin
      h = Net::HTTP.new(@server, @port)
      @resp,@data=h.delete2(path, nil)
      return @data
    rescue  SocketError => err
      puts "socket error"+err.to_s
    end
  end

  def put(path, data)
    begin
      h = Net::HTTP.new(@server, @port)
      @resp,@data=h.put(path, data)      
      return @data
    rescue  SocketError => err
      puts "socket error"+err.to_s
    end
  end
  
  def post(path, data)
    begin
      h = Net::HTTP.new(@server, @port)
      @resp,@data=h.post(path, data)      
      puts @resp.code.to_s
      return @data
    rescue  SocketError => err
      puts "socket error"+err.to_s
    end
  end
  
end

bdom = BdomReq.new("backend.antagus.de", 80)

cdom = 
"
<?xml version="1.0" encoding="UTF-8"?>
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <sld>example-nic-domain</sld>
  <contact-ids>
		<owner>ACMEA0003</owner>
		<admin>ACMEA0003</admin>
		<tech>ACMEA0003</tech>
		<zone>ACMEA0003</zone>
	</contact-ids>
	<nameservers>
		<ns>
		<hostname>ns1.ns-serve.net</hostname>
		<ip>193.254.189.162</ip>
		</ns>
		<ns>
		<hostname>ns2.ns-serve.net</hostname>
		<ip>83.243.59.34</ip>
		</ns>
	</nameservers>
</request>
"
#create
puts bdom.put("/bdom/domain/create/de/example-nic-domain/13048/", cdom)

#check
puts bdom.get("/bdom/domain/check/de/example-nic-domain/13048/")

      
      

References

XML:

RFC
W3 Group

HTTP:

RFC

DNS:

RFC