Herong's Tutorial Notes on Web Service and SOAP
Dr. Herong Yang, Version 4.00

Perl Socket Test Program for HTTP and SOAP

This chapter provides tutorial notes and example codes on the Perl socket test program for HTTP and SOAP communications. Topics include writing a simple Perl socket test program; sending HTTP 1.0 and HTTP 1.1 requests; sending SOAP 1.1 and SOAP 1.2 requests; fixing the issue caused by Content-Length; testing GetSpeech Web service.

SocketRequestResponse.pl - Socket Level Testing Program

Examples of HTTP 1.0 Requests and Responses

Examples of HTTP 1.1 Requests and Responses

SOAP 1.1 Request - Content-Length Too Small

SOAP 1.1 Request - Content-Length Too Large

SOAP 1.1 Request and Response of GetSpeech

SOAP 1.2 Request and Response of GetSpeech

Conclusions:

  • A simple Perl socket program, SocketRequestResponseBinary.pl, can be used to send both HTTP and SOAP requests to remote servers.
  • Very few Web servers support HTTP 1.0 as of 2009.
  • HTTP 1.1 request requires a the "Host" header line.
  • www.xmlme.com provides a public Web service, GetSpeech, that supports both SOAP 1.1 and SOAP 1.2.
  • The "Content-Length" header line must provides the exact number of bytes in the request content. This is very important.
  • The binmode() function should be used to read files in binary mode to avoid \r\n to \n conversion.

Dr. Herong Yang, updated in 2009
Perl Socket Test Program for HTTP and SOAP