PHP Doku:: Locating and calling services from a script which is not an SCA Component - SCA.examples.nonSCAscript.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzWeb ServicesSCABeispieleLocating and calling services from a script which is not an SCA Component

Ein Service von Reinhard Neidl - Webprogrammierung.

Beispiele

<<Calling another Service Component

Exposing a Service Component as a Web service>>

Locating and calling services from a script which is not an SCA Component

SCA components obtain proxies for other components or services as instance variables annotated with @reference, but this is not possible for a script that is not itself also a component. A client script which is not a component must use the SCA::getService() static method to obtain a proxy for a service, whether local or remote. The getService() method takes a URI as the argument. Typically this is the location of a local PHP script containing a component, or of a wsdl file, and is used in exactly the same way as the targets of the @binding annotations described in the previous section: that is, relative URIs are resolved against the location of the client script and not against the PHP include_path or current working directory.

For example, a script that needed to obtain proxies for the ExchangeRate and StockQuote services but was not a component would use the getService() method as follows:

Beispiel #1 Obtaining a proxy using getService

<?php
$exchange_rate 
SCA::getService('../ExchangeRate/ExchangeRate.php');
$stock_quote   SCA::getService('../StockQuote/StockQuote.wsdl');
?>

Methods on services can then be called on the returned proxy, just as they can in a component.

Beispiel #2 Making calls on the proxy

<?php
$quote  
$stock_quote->getQuote($ticker);
$rate   $exchange_rate->getRate($currency);
?>


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)