Version control: @(#) $Id: soapserverclass.class,v 1.9 2001/06/04 00:22:07 mlemos Exp $
SOAP server
Manuel Lemos (mlemos@acm.org)
Copyright © (C) Manuel Lemos 2001
@(#) $Id: soapserverclass.class,v 1.9 2001/06/04 00:22:07 mlemos Exp $
Processing SOAP protocol requests and generate responses.
This is a base class that provides basic SOAP services. To build a functional SOAP server you need to create a subclass. The functions processparsedmessage and generateresponsemessage need to be implemented in the subclass to define your SOAP server specific functionality. These functions are called from processmessage and generateresponse that implement the public interface of the class to be called by the applications.
string
""
Define the fault code to be returned in a fault message response when a SOAP request fails.
Set with a value defined according to SOAP standard when a fault is meant to reported as response.
string
""
Define the fault text to be returned in a fault message response when a SOAP request fails.
Set with a message explaining the cause of a fault that is meant to reported as response to a SOAP request.
string
"500 Internal Server Error"
Status message to be returned as fault response to a SOAP request sent via HTTP or a similar protocol.
Change the default value for instance to "200\n OK" if this class is meant to generate a response to a SOAP request served by a Web server that parses status headers and redefines the response body if the status code is 500.
string
"200 OK"
Status message to be returned as successful response to a SOAP request sent via HTTP or a similar protocol.
Keep the default value as it is a suitable status message for all known Web servers.
object
Compose and generate the SOAP request response XML document.
It is initialized by the createmessage function.
string
Contains the path of the SOAP request message header tag if it exists.
It is initialized by the processmessage function.
string
Contains the path of the SOAP request message body tag.
It is initialized by the processmessage function.
string
"http://schemas.xmlsoap.org/soap/envelope/"
URL of the schema of the namespace to be used in the SOAP response messages generated by this class.
Change if you intend to use other namespace schema than the default.
string
"http://schemas.xmlsoap.org/soap/encoding/"
URL of the schema of the encoding to be used in the SOAP response messages generated by this class.
Change if you intend to use other encoding schema than the default.
bool processarguments(
Validate and extract argument values of SOAP request commands.
Use this function from within processparsedmessage function overriden in a subclass of this class.
command - Name of the command of the SOAP request being processed.
path - Path of the command tag in the XML document of the SOAP request being processed.
argumenttypes - List of required SOAP request command arguments. The indexes of the associative array of this list are the names of the arguments and the array values are the respective types. Supported types are: "string", "integer", "boolean" and "float".
optionaltypes - List of optional SOAP request command arguments. The definition of the values for this argument are the same for the argumenttypes argument.
values - Reference to an associative array that will hold the values SOAP request command arguments extracted by this function. The indexes of the array are the names of the arguments and the array entries are the respective argument values.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.
bool generatecommandresponse(
Composes the response of a command of a SOAP request.
Use this function from within generateresponsemessage function overriden in a subclass of this class.
command - Name of the SOAP request command for which the response is being generated. The response XML document will have a tag with the same name in the SOAP response body section.
response - List of parameters to be included in the SOAP request command response. The entries of the list array are the name of the response parameters and the respective entry values should be associative arrays with two entries named "value" and "type". The value of the "type" entry should be one of the supported types: "string", "integer", "boolean" and "float". The value of the "value" entry should be one the value of the respective response parameter.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.
bool processparsedmessage(
Process an already pre-parsed SOAP request message.
This function should be overriden in a subclass to implement the processing of commands specific of the SOAP server being implemented by the subclass. When this function is called, the requestheaderpath contains the path of the XML tag that is the SOAP request document header. The requestbodypath contains the path of the XML tag that is the SOAP request document body. This function is responsible for creating the SOAP response message XML document when it is not a fault response.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.
bool generateresponsemessage(
Generate the response message XML output for the current SOAP request.
This function should be overriden in a subclass to implement the generation of the request responses of the SOAP server being implemented by the subclass.
response - Reference to a variable that will hold the contents of the XML document of the current SOAP request response.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.
bool processmessage(
Process a SOAP request message.
Call this function successively passing the contents of the SOAP request until it reaches the end of the message XML document.
data - SOAP request XML document data.
endofdata - Flag that indicates whether all the data SOAP request XML document data is being passed or there is still more data to be passed in subsequent calls to this function.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.
bool createmessage(
Create a XML document object already initialized with SOAP body section and an optional SOAP header section.
This function should be used when generating XML documents for SOAP request responses.
header - Flag that indicates whether the generated SOAP message XML document will contain a header section.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.
bool generateresponse(
Generate the contents of the SOAP request response message XML document.
Call this function after having called the proccemessage function even if it failed.
response - Reference to a variable that will hold the contents of the SOAP request response message XML document.
status - Reference to a variable that will hold status of SOAP request response suitable for returning to HTTP requests.
Success boolean flag. If this flag is 0 then the faultstring variable contains the error message that explains the failure and the faultcode variable contains code of the fault defined according to the SOAP standard.