- Socket Server Testing Program

This section provides a tutorial example on how to write a socket level server side testing program to receive and record request received from a client program.

The socket client test program,, works fine to verify how the Web service server works.

But I also need socket server test program to verify how my SOAP client program is doing by recording whatever received from the client. This is very important because there is no 'trace" function on the client side to see what client is sending.

Here is my socket server test program:

 * Copyright (c) 2002 All Rights Reserved.
public class SocketRequestResponseServer {
   public static void main(String[] args) {
      PrintStream out = System.out;

// Checking command line arguments
      if (args.length < 2) {
            "java SocketRequestResponseServer inFile outFile");
      String inFile = args[0];
      String outFile = args[1];

      try {
// Reading the response from a file
         File objFile = new File(inFile);
         int resLen = (int) objFile.length();
         byte[] resBytes = new byte[resLen];
         FileInputStream inStream = new FileInputStream(objFile);;

// Creating socket socket
         ServerSocket server = new ServerSocket(8888);
         out.println("Listening at 8888");
         Socket con = server.accept();
         out.println("Connection received from "

// Receiving the request
         InputStream reqStream = con.getInputStream();
         byte[] reqBytes = new byte[10240];
         int reqLen =;

// Sending the response
         OutputStream resStream = con.getOutputStream();


// Writing the request to a file 
         FileOutputStream outStream = new FileOutputStream(outFile);

// Output counts
         out.println("Request length: "+reqLen);
         out.println("Response length: "+resLen);
      } catch (Exception e) {

Note that:

Table of Contents

 About This Book

 Introduction to Web Service

 Introduction to SOAP (Simple Object Access Protocol)

 SOAP Message Structure

 SOAP Message Transmission and Processing

 SOAP Data Model

 SOAP Encoding

 SOAP RPC Presentation

 SOAP Properties Model

 SOAP MEP (Message Exchange Patterns)

 SOAP HTTP Binding

 SOAP PHP Implementations

 PHP SOAP Extension Client Programs

 PHP SOAP Extension Server Programs

 PHP SOAP Web Service Example - getTemp

 SOAP Perl Implementations

 Perl SOAP::Lite - SOAP Server-Client Communication Module

 Perl Socket Test Program for HTTP and SOAP

 Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service

 Perl SOAP::Lite for SOAP 1.2 Web Services

 Perl SOAP::Lite for WSDL

 Python SOAP Client: Zeep

 SOAP Java Implementations

Java Socket and HttpURLConnection for SOAP - Socket Client Testing Program - Socket Server Testing Program

 Capturing the HTTP Request from a Browser

 "read(byteBuf) = -1" Not Working

 Using to Send SOAP Messages

 Using HttpURLConnection to Call SOAP 1.1

 Capturing HTTP Request Generated by the HttpURLConnection Class

 Calling NumberToWords SOAP 1.1 Web Service

 Using HttpURLConnection to Call SOAP 1.2

 Calling NumberToWords SOAP 1.2 Web Service

 SAAJ - SOAP with Attachments API for Java

 SoapUI - SOAP Web Service Testing Tool

 WS-Security - SOAP Message Security Extension

 WS-Security X.509 Certificate Token

 Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

 Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

 Perl SOAP::Lite 0.710 for WSDL

 Web Services and SOAP Terminology

 Archived Tutorials


 Full Version in PDF/EPUB