SimpleSoapMonitor

public class SimpleSoapMonitor implements Runnable

The SimpleHttpMonitor is a very simple raw HTTP monitor used for testing. It is usually required to override some method in this class to provide handle the HTTP request / response event such as generating proper response for the requester.

Author:Twinsen Tsang

Fields

CONTENT_LENGTH

public static final String CONTENT_LENGTH

CONTENT_TYPE

public static final String CONTENT_TYPE

CRLF

protected static final byte[] CRLF

HD_CT_LEN

protected static final byte[] HD_CT_LEN

HD_CT_TYPE

protected static final byte[] HD_CT_TYPE

HD_SERVIER

protected static final byte[] HD_SERVIER

STATUS_200

protected static final byte[] STATUS_200

Constructors

SimpleSoapMonitor

public SimpleSoapMonitor(int port)

Explicit constructor for SimpleHttpMonitor

Parameters:
  • port – The port number listening HTTP request.

Methods

getContentLength

public synchronized int getContentLength()
Returns:The content length of last HTTP request.

getContentStream

public InputStream getContentStream()

Get the input stream containing the HTTP body content from the last HTTP request. It is different from getInputStream() because that returns the stream containing (HTTP header + HTTP body content).

Returns:the input stream containing the HTTP body content from the last HTTP request.

getContentType

public String getContentType()
Returns:The content type of last HTTP request

getHeaders

public Map getHeaders()
Returns:Get the last HTTP request header monitored.

getInputStream

public InputStream getInputStream()

Get the input stream containing the raw last HTTP request (header + content).

Returns:Get the last HTTP request content.

onAccept

protected void onAccept(Socket s)

[@EVENT] This method is invoked when a socket connection is accepted. Do nothing by default.

onRequest

protected void onRequest(InputStream ins)

[@EVENT] This method is invoked after the socket is accepted.

onResponse

protected void onResponse(OutputStream os)

[@EVENT] This method is invoked when the HTTP content has been parsed, and now ready to write content to socket.

onResponseContentType

protected String onResponseContentType()

onResponseLength

protected int onResponseLength()

[@EVENT] This method is invoked before calling onResponse. It ask the sub-class implementation for the content length of this response. Default return 0.

run

public void run()

The thread execution method.

start

public synchronized void start()

Start the HTTP monitor.

stop

public synchronized void stop()

Stop the HTTP monitor.