Distributed Programming Interfaces Over HTTP

The Extended Hypertext Transfer Protocol lets you abstract an API across a network as services, similar to web services using protocols such as SOAP, enabling remote and distributed platforms for both private and public consumption.

XHTTP differs from other protocols in that all request and response metadata are sent as headers. This significantly reduces the transport overhead involved with other solutions by integrating the process into the protocol itself.

The extension to the base protocol defines the process of constructing a request and generating a response, aswell as adding additional headers and status codes, and finally, defining an XML schema to describe the services and actions available at the URI. The specification does not modify or remove any of the existing features defined in version 1.0 and 1.1 of the HTTP specification. Features such as TLS, authentification, caching and streaming are also available when using XHTTP.

The following example shows a simple XHTTP request.

  GET http://example.com?foo=abc&bar=123 HTTP/1.1
  Host: example.com
  Version: 1.0
  Mode: perform
  Service: example;1.0
  Action: test
  Arguments: foo;4,bar;2
  Encoding: UTF-8

The Version header specifies the XHTTP version the client requires on the server, while the Mode header defines the response mode requested by the client: "version", "info", "schema" or "perform". The Service and Action headers define the service API version to load and the specific action to perform.

XHTTP allows for both primitive and complex data types, sent to the server as query string parameters and defined in the Arguments header of the request, and received by the client in the response body and defined in the Return header.

If the request were to be processed successfully, the following XHTTP response headers and body would be returned to the client:

  HTTP/1.0 200 OK
  Date: Sat, 21 Dec 2024 18:18:13 GMT 
  Return: 5
  
  ['James Watts','Madrid','Spain']

However, in the event that an error were to occur, an exception would be thrown as the response, for example:

  HTTP/1.0 550 Exception
  Date: Sat, 21 Dec 2024 18:18:13 GMT 
  Exception: You must pass a string of text;9

Allowing services to throw exceptions at the protocol level gives them the ability to be chained and combined together without needing to introduce fault tolerance into the application logic. This gives the protocol control over the flow of their execution, by handling exceptions as part of the communication process between requests.

Service-Orientated Architecture Protocol

To allow for interoperability between implementations of the protocol the XHTTP schema provides a singular method to define the services and their actions exposed by the server. This allows for services to be distributed not only over multiple servers but also between diferent implementations and programming languages.

The following is the XHTTP schema of the previous example.

  <?xml version="1.0" encoding="UTF-8"?>
  <xhttp xmlns:xhttp="http://www.xhttp.org/schema" version="1.0">
      <xhttp:schema version="1.2">
          <xhttp:info name="service" value="example"/>
          <xhttp:info name="host" value="http://example.com"/>
          <xhttp:info name="port" value="80"/>
          <xhttp:info name="author" value="James Watts (SOLFENIX)"/>
          <xhttp:info name="email" value="jameswatts@solfenix.com"/>
          <xhttp:info name="link" value="http://www.solfenix.com"/>
          <xhttp:info name="version" value="1.2"/>
          <xhttp:info name="build" value="20110201"/>
          <xhttp:action name="test" function="test">
              <xhttp:exception code="9" message="You must pass a string of text"/>
              <xhttp:argument name="foo" type="4" use="required"/>
              <xhttp:argument name="bar" type="2"/>
              <xhttp:return type="5"/>
          </xhttp:action>
      </xhttp:schema>
  </xhttp>

The XHTTP schema allows for versioning of services, aswell as exposing the service's or individual action's structure for remote instanciation of its API. For example, the following is a request for the "example" service's schema.

  GET http://example.com HTTP/1.1
  Host: example.com
  Version: 1.0
  Mode: schema
  Service: example;1.0

The structure returned in the response can then be used to create a remote image of the service's API.

  HTTP/1.1 200 OK
  Date: Sat, 21 Dec 2024 18:18:13 GMT 
  Return: 5
  
  [["test",[["You must pass a string of text",9]],[["foo",4,true],["bar",2,false]],5]]

For example, in Java, this response could be represented as a class:

  public class Example { // service as the class, with actions as methods
  
      public static function String[] test( String foo ) // foo is required
      {
          ...
          
          return ... // call to server would return an array
      }
  
      public static function String[] test( String foo, int bar ) // bar is optional
      {
          ...
      }
  }
  
  String[] result = Example.test( 'abc', 123 );

To learn more about the Extended Hypertext Transfer Protocol see the specification, the protocol overview, or try out the libraries already available in your preferred programming language.

CodeMessageLineFile
2session_start(): open(/var/cpanel/php/sessions/ea-php82/sess_25bfe73589d9983950ef0094b1e701cf, O_RDWR) failed: No such file or directory (2)67/home2/xhttporg/public_html/pagetype/cms.php
2session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/ea-php82)67/home2/xhttporg/public_html/pagetype/cms.php
8192Creation of dynamic property PageTypeCMS::$html is deprecated43/home2/xhttporg/public_html/pagetype/plugins/html/pagetype.plugin.php