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:
- <services>
- <service id="soap" class="System.Web.Services.TSoapService">
- <soap id="stockquote" provider="MyStockQuote" />
- </service>
- </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:
- 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,
- class MyStockQuote {
- / **
- * @param string $symbol the stock symbol
- * @return float the stock price
- * @soapmethod
- * /
- public function getQuote($symbol) {...}
- }
With the above SOAP provider, a typical SOAP client may call the method "getQuote" remotely like the following:
- $client=new SoapClient("http://hostname/path/to/index.php?soap=stockquote.wsdl");
- 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)
- <services>
- <service id="soap" class="System.Web.Services.TSoapService">
- <soap id="stockquote" provider="MyStockQuote" SessionPersistent="true" />
- </service>
- </services>
You may also use your own SOAP server class by specifying the "class" attribute of <soap>.
Method Details |
constructUrl
public string constructUrl |
(string $serverID , array $getParams , boolean $encodeAmpersand , boolean $encodeGetItems ) |
Constructs a URL with specified page path and GET parameters.
Input |
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. |
Output |
string
| URL for the page and GET parameters |
Exception |
|
createServer
Creates the requested SOAP server.
The SOAP server is initialized with the property values specified in the configuration.
|
getConfigFile
public string getConfigFile |
() |
Output |
string
| external configuration file. Defaults to null. |
Exception |
|
getIsWsdlRequest
public boolean getIsWsdlRequest |
() |
Output |
boolean
| whether this is a request for WSDL |
Exception |
|
getServerID
public string getServerID |
() |
Output |
string
| the SOAP server ID |
Exception |
|
init
Initializes this module.
This method is required by the IModule interface.
Input |
TXmlElement | $config | configuration for this module, can be null |
Output |
Exception |
throws | TConfigurationException if ConfigFile is invalid. |
|
resolveRequest
protected void resolveRequest |
() |
Resolves the request parameter.
It identifies the server ID and whether the request is for WSDL.
Output |
Exception |
throws | THttpException if the server ID cannot be found |
|
run
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.
|
setConfigFile
public void setConfigFile |
(string $value ) |
Input |
string | $value | external configuration file in namespace format. The file must be suffixed with '.xml'. |
Output |
Exception |
throws | TInvalidDataValueException if the file is invalid. |
|