Sophie

Sophie

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

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>Understanding how the WSDL is generated</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sca.examples.obtaining-wsdl.html">Obtaining the WSDL for an SCA component offering a Service as
   a Web service</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.examples.structures.html">Working with Data Structures</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.understanding-wsdl" class="section">
  <h2 class="title"> Understanding how the WSDL is generated </h2>
  <p class="para"> 
   SCA for PHP generates WSDL for components which contain an
   @binding.soap annotation after the @service annotation. To
   generate WSDL, the SCA runtime reflects on the component and
   examines the @param and @return annotations for each public
   method, as well as any @types annotations within the component. The
   information from the @param and @return annotations is used to
   build the &lt;types&gt; section of the WSDL. Any @types
   annotations which specify a separate schema file will result in an
   &lt;import&gt; element for that schema within the WSDL.
  </p>
  
  <div class="section" id="sca.examples.understanding-wsdl.location">
   <h2 class="title"> Location attribute of the &lt;service&gt; element</h2>
   <p class="para"> 
    At the bottom of the WSDL is the &lt;service&gt; element
    which uses the location attribute to identify the URL of the
    service. For example this might look as follows: 
   </p>
   
   <p class="para">
    <div class="example" id="example-5305">
     <p><strong>Example #1  location attribute </strong></p>
     <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;service name=&quot;ConvertedStockQuote&quot;
...
location=&quot;http://localhost/ConvertedStockQuote/ConvertedStockQuote.php&quot;/&gt;</pre>
</div>
     </div>

    </div>
   </p>
   <p class="para">
    Note that this location is relative to the document root of
    the web server, and cannot be worked out in advance. It can only be
    worked out once the component is in its proper place under a running
    web server, when the hostname and port can be known and placed in the
    WSDL. Detail from the URL that requests the WSDL is used, so for
    example if the WSDL is generated in response to a request to
    http://www.example.com:1111/ConvertedStockQuote/ConvertedStockQuote.php?wsdl,
    a location of
    http://www.example.com:1111/ConvertedStockQuote/ConvertedStockQuote.php
    is what will be inserted into the location attribute in the WSDL.
   </p>
  </div>
  
    
  <div class="section" id="sca.examples.understanding-wsdl.positional-parameters"> 
   <h2 class="title">Document/literal wrapped WSDL and positional
    parameters</h2>
   <p class="para"> 
    SCA for PHP generates WSDL in the document/literal wrapped
    style. This style encloses the parameters and return types of a
    method in &#039;wrappers&#039; which are named after the corresponding
    method. The &lt;types&gt; element at the top of the WSDL defines
    each of these wrappers. If we consider the
     <span class="function"><strong>getQuote()</strong></span> method of the
    ConvertedStockQuote example: 
   </p>
   
   <p class="para">
    <div class="example" id="example-5306">
     <p><strong>Example #2  method with two arguments </strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&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&nbsp;in&nbsp;a&nbsp;given&nbsp;currency.<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;@param&nbsp;string&nbsp;$currency&nbsp;What&nbsp;currency&nbsp;to&nbsp;convert&nbsp;the&nbsp;value&nbsp;to.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;float&nbsp;The&nbsp;stock&nbsp;value&nbsp;is&nbsp;the&nbsp;target&nbsp;currency.<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;</span><span style="color: #0000BB">$currency</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$quote&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stock_quote</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #0000BB">$ticker</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$rate&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exchange_rate</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRate</span><span style="color: #007700">(</span><span style="color: #0000BB">$currency</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;&nbsp;</span><span style="color: #0000BB">$rate&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">$quote</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
        
     </div>

    </div>
   </p>
   
   <p class="para">
    The WSDL generated to define this method will name both the
    method and the parameters, and give an XML schema type for the
    parameters. The types section of the WSDL looks like this: 
   </p>
   
   <p class="para">
    <div class="example" id="example-5307">
     <p><strong>Example #3  types section illustrating named parameters </strong></p>
     <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;types&gt;
    &lt;xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
      targetNamespace=&quot;http://ConvertedStockQuote&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:element name=&quot;currency&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;</pre>
</div>
     </div>

    </div>
   </p>
   
   <p class="para">
    The SCA run-time has special processing to handle how
    positional parameter lists in the interface are converted to XML
    containing named parameters in the soap request, and then back to
    positional parameter lists again. To see why this matters,
    consider how a PHP script which used a different interface to make a
    SOAP call would need to construct the parameter list. A PHP script
    using the PHP SoapClient, for example, would need to pass the
    SoapClient a single parameter giving the values for &quot;ticker&quot; and
    &quot;currency&quot;, perhaps as an associative array. To insist that SCA
    components construct parameter lists to make Web service calls in
    this way would be to make local and remote calls look different, so a
    different approach is needed. 
   </p>
   
   <p class="para">
    When SCA generates WSDL for an SCA component it includes a
    comment in the WSDL which marks that WSDL as being the interface for
    an SCA component. In this case, when one SCA component calls
    another through a Web service, the SCA runtime on the calling end
    takes the positional parameter list from the call and assigns the
    values one by one to the named elements in the soap message. For
    example a call to the
     <span class="function"><strong>getQuote()</strong></span> method defined above that
    passes the values &#039;IBM&#039; and &#039;USD&#039; and looks like this: 
   </p>
   
   <p class="para">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$quote&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$remote_service</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #DD0000">'IBM'</span><span style="color: #007700">,</span><span style="color: #DD0000">'USD'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </p>
   
   <p class="para">
    will result in a soap message containing the
    following:
   </p>
   
   <p class="para">
    <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;getQuote&gt;
  &lt;ticker&gt;IBM&lt;/ticker&gt;
  &lt;currency&gt;USD&lt;/currency&gt;
&lt;/getQuote&gt;</pre>
</div>
    </div>

   </p>
   
   <p class="para">
    On the service-providing end, the SCA run-time takes the
    parameters one by one from the soap message and forms a positional
    parameter list from them, re-forming the argument list
    (&#039;IBM&#039;,&#039;USD&#039;).
   </p>
   
   <div class="caution"><strong class="caution">Caution</strong>
    
    <p class="para"> 
     At both ends the SCA runtime relies on the order in which the
     parameters appear in the soap message being the same as that in the
     target method&#039;s parameter list. This is ultimately determined
     by the order of the @param annotations: this determines the order
     in which the parameters appear in the WSDL and thereby the order in
     which they appear in the soap message. Therefore it is essential
     that the order of the @param annotations matches that of the
     parameters in the method&#039;s parameter list. 
    </p>
   </div>
   
  </div>
  
    
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sca.examples.obtaining-wsdl.html">Obtaining the WSDL for an SCA component offering a Service as
   a Web service</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.examples.structures.html">Working with Data Structures</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>