Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 11127

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Exposing a Service Component as a Web service</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sca.examples.nonscascript.html">Locating and calling services from a script which is not an
   SCA Component</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.examples.deploy.html">Deploying an SCA component</a></div>
 <div class="up"><a href="sca.examples.html">Examples</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sca.examples.exposing-webservice" class="section">
  <h2 class="title"> Exposing a Service Component as a Web service </h2>
  
  <p class="para"> 
   SCA for PHP can generate WSDL from the annotations within a
   service component, so that it can be easily deployed and exposed as a
   Web service. To provide SCA with the information it needs to
   generate the WSDL, it is necessary to add the annotation
   @binding.soap under the @service annotation and to specify the
   parameters and return values of the methods using the @param and
   @return annotations. These annotations will be read when WSDL is
   generated, and the order and types of the parameters determine the
   contents of the
   &lt;schema&gt; section of the WSDL. 
  </p>
  
  <p class="para"> 
   SCA for PHP always generates document/literal wrapped WSDL
   for components that are exposing a Web service. Note that this does
   not stop components from consuming Web services which are not SCA
   components and which are documented with WSDL written in a
   different style. 
  </p>
  
  <p class="para"> 
   The scalar types which can be used in the @param annotation are
   the four common PHP scalar types: boolean, integer, float and
   string. These are simply mapped to the XML schema types of the same
   name in the WSDL. The example below, which is a trivial
   implementation of the StockQuote service that the
   ConvertedStockQuote component calls, illustrates string and
   float types. 
  </p>
  
  <p class="para">
   <div class="example" id="example-5302">
    <p><strong>Example #1  StockQuote Service </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"SCA/SCA.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Scaffold&nbsp;implementation&nbsp;for&nbsp;a&nbsp;remote&nbsp;StockQuote&nbsp;Web&nbsp;service.<br />&nbsp;*<br />&nbsp;*&nbsp;@service<br />&nbsp;*&nbsp;@binding.soap<br />&nbsp;*<br />&nbsp;*/<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">StockQuote&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Get&nbsp;a&nbsp;stock&nbsp;quote&nbsp;for&nbsp;a&nbsp;given&nbsp;ticker&nbsp;symbol.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$ticker&nbsp;The&nbsp;ticker&nbsp;symbol.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;float&nbsp;The&nbsp;stock&nbsp;quote.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #0000BB">$ticker</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">80.9</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  
  <p class="para"> 
   WSDL much like the following (though with a service location
   other than &#039;localhost&#039;, probably) would be generated from this
   service:
  </p>
  
  <p class="para">
   <div class="example" id="example-5303">
    <p><strong>Example #2  Generated WSDL </strong></p>
    <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;definitions xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot; xsi:type=&quot;tDefinitions&quot;
    xmlns:tns2=&quot;http://StockQuote&quot; xmlns:tns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
    xmlns:tns3=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; targetNamespace=&quot;http://StockQuote&quot;&gt;
  &lt;types&gt;
    &lt;xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
      targetNamespace=&quot;http://StockQuote&quot;&gt;
      &lt;xs:element name=&quot;getQuote&quot;&gt;
        &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name=&quot;ticker&quot; type=&quot;xs:string&quot;/&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name=&quot;getQuoteResponse&quot;&gt;
        &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name=&quot;getQuoteReturn&quot; type=&quot;xs:float&quot;/&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:schema&gt;
  &lt;/types&gt;

  &lt;message name=&quot;getQuoteRequest&quot;&gt;
    &lt;part name=&quot;getQuoteRequest&quot; element=&quot;tns2:getQuote&quot;/&gt;
  &lt;/message&gt;
  &lt;message name=&quot;getQuoteResponse&quot;&gt;
    &lt;part name=&quot;return&quot; element=&quot;tns2:getQuoteResponse&quot;/&gt;
  &lt;/message&gt;
  &lt;portType name=&quot;StockQuotePortType&quot;&gt;
    &lt;operation name=&quot;getQuote&quot;&gt;
      &lt;input message=&quot;tns2:getQuoteRequest&quot;/&gt;
      &lt;output message=&quot;tns2:getQuoteResponse&quot;/&gt;
    &lt;/operation&gt;
  &lt;/portType&gt;
  &lt;binding name=&quot;StockQuoteBinding&quot; type=&quot;tns2:StockQuotePortType&quot;&gt;
    &lt;operation name=&quot;getQuote&quot;&gt;
      &lt;input&gt;
        &lt;tns3:body xsi:type=&quot;tBody&quot; use=&quot;literal&quot;/&gt;
      &lt;/input&gt;
      &lt;output&gt;
        &lt;tns3:body xsi:type=&quot;tBody&quot; use=&quot;literal&quot;/&gt;
      &lt;/output&gt;
      &lt;tns3:operation xsi:type=&quot;tOperation&quot; soapAction=&quot;&quot;/&gt;
    &lt;/operation&gt;
    &lt;tns3:binding xsi:type=&quot;tBinding&quot; transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; style=&quot;document&quot;/&gt;
  &lt;/binding&gt;
  &lt;service name=&quot;StockQuoteService&quot;&gt;
    &lt;port name=&quot;StockQuotePort&quot; binding=&quot;tns2:StockQuoteBinding&quot;&gt;
      &lt;tns3:address xsi:type=&quot;tAddress&quot; location=&quot;http://localhost/StockQuote/StockQuote.php&quot;/&gt;
    &lt;/port&gt;
  &lt;/service&gt;
&lt;/definitions&gt;

&lt;!-- this line identifies this file as WSDL generated by SCA for PHP. Do not remove --&gt;</pre>
</div>
       
    </div>

   </div>
  </p>
  
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sca.examples.nonscascript.html">Locating and calling services from a script which is not an
   SCA Component</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.examples.deploy.html">Deploying an SCA component</a></div>
 <div class="up"><a href="sca.examples.html">Examples</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>