HTTP tutorial - Request and response

For a complete HTTP process, an XML is sent to the local webserver, which reacts with a corresponding response.

HTTP POST request
POST /dw/Request/xml_calc HTTP/1.1
Content-Type: application/xml
Host: localhost:10443
Content-Length: 114
 
<?xml version="1.0" encoding="utf-8"?>
<Calculate>
<OP1>12</OP1>
<OP2>3</OP2>
<OPR>/</OPR>
</Calculate>
HTTP POST response
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 64
 
<?xml version="1.0" encoding="UTF-8"?>
<RESULT>4</RESULT>

Structure of the POST request


Line 1 of the request POST /dw/Request/xml_calc HTTP/1.1 belongs neither to the header nor to the body, but rather represents a kind of meta information.

In each HTTP call, three information fragments must first be specified:


  • Method: POST.

  • Requested resource URI.

  • HTTP version.


The information line is followed by the header section, whereby the information (reduced to a minimum here) can be placed anywhere:


  • In line 2 the type of payload is specified (MIME type).

  • Line 3 contains the host header as the location of the resource (URL).

  • In line 4, the Content-Length header is specified. Note: The Content-Length header is the only header that can never be set manually. The correct length is always calculated automatically.


(Lines 2 and 4 are not necessary in methods such as GET or HEAD, as there is no body in this case.)


The header and body sections are always automatically separated by a blank line. A blank line must never be inserted here manually, as the following content is no longer considered.

Structure of the response


If the request has been properly received and processed by the partner, the partner sends back a corresponding response:


  • Line 1 gives meta information similar to the call; here the HTTP version used and information about the status of the action is given.

  • From line 2 follows the header section with value pairs that the server sets; here the MIME-Type and the Content-Length (character length).

  • The body is preceded by a blank line.


Note: In Postman, use the console under the menu item View - Show Postman Console, to get an idea of the structure of an HTTP request. Here, the request and response are displayed in detail, which is helpful for troubleshooting.