Class TSoapService

Description

TSoapService class

TSoapService processes SOAP requests for a PRADO application. TSoapService requires PHP SOAP extension to be loaded.

TSoapService manages a set of SOAP providers. Each SOAP provider is a class that implements a set of SOAP methods which are exposed to SOAP clients for remote invocation. TSoapService generates WSDL automatically for the SOAP providers by default.

To use TSoapService, configure it in the application specification like following:

  1. <services>
  2. <service id="soap" class="System.Web.Services.TSoapService">
  3. <soap id="stockquote" provider="MyStockQuote" />
  4. </service>
  5. </services>

The above example specifies a single SOAP provider named "stockquote" whose class is "MyStockQuote". A SOAP client can then obtain the WSDL for this provider via the following URL:

  1. http://hostname/path/to/index.php?soap=stockquote.wsdl

The WSDL for the provider class "MyStockQuote" is generated based on special comment tags in the class. In particular, if a class method's comment contains the keyword "@soapmethod", it is considered to be a SOAP method and will be exposed to SOAP clients. For example,

  1. class MyStockQuote {
  2. / **
  3. * @param string $symbol the stock symbol
  4. * @return float the stock price
  5. * @soapmethod
  6. * /
  7. public function getQuote($symbol) {...}
  8. }

With the above SOAP provider, a typical SOAP client may call the method "getQuote" remotely like the following:

  1. $client=new SoapClient("http://hostname/path/to/index.php?soap=stockquote.wsdl");
  2. echo $client->getQuote("ibm");

Each <soap> element in the application specification actually configures the properties of a SOAP server which defaults to TSoapServer. Therefore, any writable property of TSoapServer may appear as an attribute in the <soap> element. For example, the "provider" attribute refers to the TSoapServer::setProvider property of TSoapServer. The following configuration specifies that the SOAP server is persistent within the user session (that means a MyStockQuote object will be stored in session)

  1. <services>
  2. <service id="soap" class="System.Web.Services.TSoapService">
  3. <soap id="stockquote" provider="MyStockQuote" SessionPersistent="true" />
  4. </service>
  5. </services>

You may also use your own SOAP server class by specifying the "class" attribute of <soap>.

Located in /Web/Services/TSoapService.php (line 85)

TComponent
   |
   --TApplicationComponent
      |
      --TService
         |
         --TSoapService
Class Constant Summary
 CONFIG_FILE_EXT = '.xml'
 DEFAULT_SOAP_SERVER = 'TSoapServer'
Method Summary
TSoapService __construct ()
string constructUrl (string $serverID, [array $getParams = null], [boolean $encodeAmpersand = true], [boolean $encodeGetItems = true])
string getConfigFile ()
boolean getIsWsdlRequest ()
string getServerID ()
void init (TXmlElement $config)
void resolveRequest ()
void run ()
void setConfigFile (string $value)
Methods
Constructor __construct (line 98)

Constructor.

Sets default service ID to 'soap'.

  • access: public
TSoapService __construct ()
constructUrl (line 194)

Constructs a URL with specified page path and GET parameters.

  • return: URL for the page and GET parameters
  • access: public
string constructUrl (string $serverID, [array $getParams = null], [boolean $encodeAmpersand = true], [boolean $encodeGetItems = true])
  • string $serverID: soap server ID
  • array $getParams: list of GET parameters, null if no GET parameters required
  • boolean $encodeAmpersand: whether to encode the ampersand in URL, defaults to true.
  • boolean $encodeGetItems: whether to encode the GET parameters (their names and values), defaults to true.
createServer (line 221)

Creates the requested SOAP server.

The SOAP server is initialized with the property values specified in the configuration.

  • return: the SOAP server instance
  • access: protected
TSoapServer createServer ()
getConfigFile (line 170)
  • return: external configuration file. Defaults to null.
  • access: public
string getConfigFile ()
getIsWsdlRequest (line 202)
  • return: whether this is a request for WSDL
  • access: public
boolean getIsWsdlRequest ()
getServerID (line 210)
  • return: the SOAP server ID
  • access: public
string getServerID ()
init (line 109)

Initializes this module.

This method is required by the IModule interface.

  • access: public
  • throws: TConfigurationException if ConfigFile is invalid.
void init (TXmlElement $config)
  • TXmlElement $config: configuration for this module, can be null

Redefinition of:
TService::init()
Initializes the service and attaches run to the RunService event of application.
resolveRequest (line 134)

Resolves the request parameter.

It identifies the server ID and whether the request is for WSDL.

void resolveRequest ()
run (line 243)

Runs the service.

If the service parameter ends with '.wsdl', it will serve a WSDL file for the specified soap server. Otherwise, it will handle the soap request using the specified server.

  • access: public
void run ()

Redefinition of:
TService::run()
Runs the service.
setConfigFile (line 180)
  • access: public
  • throws: TInvalidDataValueException if the file is invalid.
void setConfigFile (string $value)
  • string $value: external configuration file in namespace format. The file must be suffixed with '.xml'.

Inherited Methods

Inherited From TService

TService::getEnabled()
TService::getID()
TService::init()
TService::run()
TService::setEnabled()
TService::setID()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants
CONFIG_FILE_EXT = '.xml' (line 88)
DEFAULT_SOAP_SERVER = 'TSoapServer' (line 87)

Documentation generated on Mon, 21 Apr 2008 11:36:14 -0400 by phpDocumentor 1.3.0RC4