📄 sca.examples.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Examples</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sca.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="SCA.examples.proxies.html">Obtaining a proxy for another Service Component</a></div> <div class="up"><a href="book.sca.html">SCA</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Examples</h1><h2>Table of Contents</h2><ul class="chunklist chunklist_chapter"><li><a href="SCA.examples.proxies.html">Obtaining a proxy for another Service Component</a></li><li><a href="SCA.examples.calling.html">Calling another Service Component</a></li><li><a href="SCA.examples.nonSCAscript.html">Locating and calling services from a script which is not an SCA Component</a></li><li><a href="sca.examples.exposing-webservice.html">Exposing a Service Component as a Web service</a></li><li><a href="SCA.examples.deploy.html">Deploying an SCA component</a></li><li><a href="SCA.examples.obtaining-wsdl.html">Obtaining the WSDL for an SCA component offering a Service as a Web service</a></li><li><a href="SCA.examples.understanding-wsdl.html">Understanding how the WSDL is generated</a></li><li><a href="SCA.examples.structures.html">Working with Data Structures</a></li><li><a href="SCA.examples.errorhandling.html">Error handling</a></li></ul> <p class="para"> The examples in the subsequent sections illustrate the following aspects of PHP for SCA: </p> <ul class="itemizedlist"> <li class="listitem"> <p class="para"> How PHP annotations are used to define PHP classes as SCA components, and how annotations are used to define the services. </p> </li> <li class="listitem"> <p class="para"> How an SCA component can be exposed as a Web service </p> </li> <li class="listitem"> <p class="para"> How an SCA component can consume a Web service, whether provided by another SCA component or by some other service which knows nothing of SCA </p> </li> <li class="listitem"> <p class="para"> How an SCA component can call another SCA component locally (within the same process and on the same call stack) </p> </li> <li class="listitem"> <p class="para"> How a client script which is not an SCA component can use the getService call to obtain a proxy for an SCA component. </p> </li> <li class="listitem"> <p class="para"> How data structures such as Addresses, or Puchase Orders, are represented as Service Data Objects, and handled. </p> </li> <li class="listitem"> <p class="para"> How SCA components are deployed, and in particular how and when WSDL is generated for a service. </p> </li> <li class="listitem"> <p class="para"> How parameters are always passed by value (and not by reference) between components, even when the calls are local. This ensures that the semantics of a call do not change depending on the location of a component. </p> </li> <li class="listitem"> <p class="para"> How positional parameters to a service are supported, even when the underlying WSDL is document literal wrapped, and naturally supports only named parameters. </p> </li> <li class="listitem"> <p class="para"> How business and runtime exceptions are handled. </p> </li> </ul> <div id="SCA.examples.structure" class="section"> <h2 class="title">The structure of a Service Component</h2> <p class="para"> A service component is implemented by a class. To identify it as a service component, it contains an @service annotation. The SCA runtime will use the file name of the script to determine the component name, by convention. The class and script file must therefore share the same name. </p> <p class="para"> PHP SCA components always expose a service, and there is no way for a component to be invoked other than to be called as a result of a Web service request, or called directly from another component or from a script. For this reason a valid PHP SCA component will always contain an @service annotation and at least one public method. </p> <p class="para"> Each SCA Component requires that the SCA.php script is included. As well as containing the definition of the SCA class, this script contains executable PHP code that will run whenever the script is called, and which will be responsible for making the component behave as needed. </p> <div class="caution"><b class="caution">Caution</b> <p class="para"> It is very important that if your file contains other includes, they come before the include for SCA.php. If there are includes after the include for SCA.php, they will not have been processed when the SCA runtime runs your class. </p> </div> <p class="para"> The example below illustrates this overall structure </p> <p class="para"> <div class="example"> <p><b>Example #1 The structure of an SCA for PHP component </b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// any includes<br /><br /></span><span style="color: #007700">include </span><span style="color: #DD0000">"SCA/SCA.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/**<br /> * @service<br /> */<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">ConvertedStockQuote </span><span style="color: #007700">{<br /><br /> </span><span style="color: #FF8000">// instance variables, business logic, including at least one public method<br /><br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sca.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="SCA.examples.proxies.html">Obtaining a proxy for another Service Component</a></div> <div class="up"><a href="book.sca.html">SCA</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -