Ignore:
Timestamp:
2011/10/25 00:02:55 (12 years ago)
Author:
Seasoft
Message:

#1521 (PEAR::SOAP 配布と異なる部分がある)

  • 新しいバージョンの配布ファイルを上書きすることで解決

#1522 (PEAR::SOAP をバージョンアップ)

  • 0.11.0 -> 0.12.0
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_11-dev/data/module/SOAP/example/example_server.php

    r20119 r21299  
    11<?php 
    2 // 
    3 // +----------------------------------------------------------------------+ 
    4 // | PHP Version 4                                                        | 
    5 // +----------------------------------------------------------------------+ 
    6 // | Copyright (c) 1997-2003 The PHP Group                                | 
    7 // +----------------------------------------------------------------------+ 
    8 // | This source file is subject to version 2.02 of the PHP license,      | 
    9 // | that is bundled with this package in the file LICENSE, and is        | 
    10 // | available at through the world-wide-web at                           | 
    11 // | http://www.php.net/license/2_02.txt.                                 | 
    12 // | If you did not receive a copy of the PHP license and are unable to   | 
    13 // | obtain it through the world-wide-web, please send a note to          | 
    14 // | license@php.net so we can mail you a copy immediately.               | 
    15 // +----------------------------------------------------------------------+ 
    16 // | Authors: Shane Caraveo <Shane@Caraveo.com>                           | 
    17 // +----------------------------------------------------------------------+ 
    18 // 
    19 // $Id: example_server.php,v 1.6 2007/01/22 11:51:45 yunosh Exp $ 
    20 // 
     2/** 
     3 * Example server. 
     4 * 
     5 * PHP versions 4 and 5 
     6 * 
     7 * LICENSE: This source file is subject to version 2.02 of the PHP license, 
     8 * that is bundled with this package in the file LICENSE, and is available at 
     9 * through the world-wide-web at http://www.php.net/license/2_02.txt.  If you 
     10 * did not receive a copy of the PHP license and are unable to obtain it 
     11 * through the world-wide-web, please send a note to license@php.net so we can 
     12 * mail you a copy immediately. 
     13 * 
     14 * @category   Web Services 
     15 * @package    SOAP 
     16 * @author     Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more 
     17 * @author     Jan Schneider <jan@horde.org>       Maintenance 
     18 * @copyright  2003-2007 The PHP Group 
     19 * @license    http://www.php.net/license/2_02.txt  PHP License 2.02 
     20 * @link       http://pear.php.net/package/SOAP 
     21 */ 
    2122 
    22 // first, include the SOAP/Server class 
     23/** SOAP_Value */ 
    2324require_once 'SOAP/Value.php'; 
    2425require_once 'SOAP/Fault.php'; 
    2526 
    26 // SOAPStruct is defined in the following file 
    27 require_once 'example_types.php'; 
     27/** SOAPStruct */ 
     28require_once dirname(__FILE__) . '/example_types.php'; 
    2829 
    29 // create a class for your soap functions 
     30/* Create a class for your SOAP functions. */ 
    3031class SOAP_Example_Server { 
    31     /** 
    32      * The dispactch map does not need to be used, but aids 
    33      * the server class in knowing what parameters are used 
    34      * with the functions.  This is the ONLY way to have 
    35      * multiple OUT parameters.  If you use a dispatch map, you 
    36      * MUST add ALL functions you wish to allow be called.  If 
    37      * you do not use a dispatch map, then any public function 
    38      * can be called from soap (in php4, we consider this to be 
    39      * any function in the class unless it starts with underscore, 
    40      * php5 support is not complete yet in this regard).   
    41      * if you do not define in/out parameters, the function can be 
    42      * called with parameters, but no validation on parameters will 
    43      * occure. 
    44      */ 
     32    /* The dispatch map does not need to be used, but aids the server class in 
     33     * knowing what parameters are used with the functions.  This is the ONLY 
     34     * way to have multiple OUT parameters.  If you use a dispatch map, you 
     35     * MUST add ALL functions you wish to allow be called.  If you do not use 
     36     * a dispatch map, then any public function can be called from SOAP. We 
     37     * consider this to be any function in the class unless it starts with 
     38     * underscore.  If you do not define in/out parameters, the function can 
     39     * be called with parameters, but no validation on parameters will 
     40     * occur. */ 
    4541    var $__dispatch_map = array(); 
    4642 
    4743    function SOAP_Example_Server() { 
    48         /** 
    49         * when generating wsdl for a server, you have to define 
    50         * any special complex types that you use (ie classes). 
    51         * using a namespace id before the type will create an 
    52         * xml schema with the targetNamespace for the type 
    53         * multiple types with the same namespace will appear 
    54         * in the same schema section.  types with different 
    55         * namespaces will be in seperate schema sections. 
    56         * the following SOAPStruct typedef cooresponds to the 
    57         * SOAPStruct class above. 
    58         */ 
    59         $this->__typedef['{http://soapinterop.org/xsd}SOAPStruct'] =  
    60                     array( 
    61                         'varString' => 'string', 
    62                         'varInt' => 'int',  
    63                         'varFloat' => 'float' 
    64                          ); 
     44        /* When generating WSDL for a server, you have to define any special 
     45         * complex types that you use (ie classes).  Using a namespace id 
     46         * before the type will create an XML schema with the targetNamespace 
     47         * for the type multiple types with the same namespace will appear in 
     48         * the same schema section.  Types with different namespaces will be 
     49         * in seperate schema sections.  The following SOAPStruct typedef 
     50         * cooresponds to the SOAPStruct class above. */ 
     51        $this->__typedef['{http://soapinterop.org/xsd}SOAPStruct'] = 
     52            array('varString' => 'string', 
     53                  'varInt' => 'int', 
     54                  'varFloat' => 'float'); 
    6555 
    66         // an aliased function with multiple out parameters 
    67     $this->__dispatch_map['echoStructAsSimpleTypes'] = 
    68         array('in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 
    69               'out' => array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float'), 
    70               'alias' => 'myEchoStructAsSimpleTypes' 
    71               ); 
    72     $this->__dispatch_map['echoStringSimple'] = 
    73         array('in' => array('inputStringSimple' => 'string'), 
    74               'out' => array('outputStringSimple' => 'string'), 
    75               ); 
    76     $this->__dispatch_map['echoString'] = 
    77         array('in' => array('inputString' => 'string'), 
    78               'out' => array('outputString' => 'string'), 
    79               ); 
    80     $this->__dispatch_map['divide'] = 
    81         array('in' => array('dividend' => 'int', 'divisor' => 'int'), 
    82               'out' => array('outputFloat' => 'float'), 
    83               ); 
    84     $this->__dispatch_map['echoStruct'] = 
    85         array('in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 
    86               'out' => array('outputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 
    87               ); 
    88      
    89     $this->__dispatch_map['echoMimeAttachment'] = array(); 
     56        /* An aliased function with multiple out parameters. */ 
     57        $this->__dispatch_map['echoStructAsSimpleTypes'] = 
     58            array('in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 
     59                  'out' => array('outputString' => 'string', 
     60                                 'outputInteger' => 'int', 
     61                                 'outputFloat' => 'float'), 
     62                  'alias' => 'myEchoStructAsSimpleTypes'); 
     63        $this->__dispatch_map['echoStringSimple'] = 
     64            array('in' => array('inputStringSimple' => 'string'), 
     65                  'out' => array('outputStringSimple' => 'string')); 
     66        $this->__dispatch_map['echoString'] = 
     67            array('in' => array('inputString' => 'string'), 
     68                  'out' => array('outputString' => 'string')); 
     69        $this->__dispatch_map['divide'] = 
     70            array('in' => array('dividend' => 'int', 
     71                                'divisor' => 'int'), 
     72                  'out' => array('outputFloat' => 'float')); 
     73        $this->__dispatch_map['echoStruct'] = 
     74            array('in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 
     75                  'out' => array('outputStruct' => '{http://soapinterop.org/xsd}SOAPStruct')); 
     76 
     77        $this->__dispatch_map['echoMimeAttachment'] = 
     78            array('in' => array('stuff' => 'string'), 
     79                  'out' => array('outputMime' => 'string')); 
    9080    } 
    9181 
    92     /* this private function is called on by SOAP_Server to determine any 
    93         special dispatch information that might be necessary.  This, for example, 
    94         can be used to set up a dispatch map for functions that return multiple 
    95         OUT parameters */ 
    96     function __dispatch($methodname) { 
    97         if (isset($this->__dispatch_map[$methodname])) 
     82    /* This private function is called on by SOAP_Server to determine any 
     83     * special dispatch information that might be necessary.  This, for 
     84     * example, can be used to set up a dispatch map for functions that return 
     85     * multiple OUT parameters. */ 
     86    function __dispatch($methodname) 
     87    { 
     88        if (isset($this->__dispatch_map[$methodname])) { 
    9889            return $this->__dispatch_map[$methodname]; 
    99         return NULL; 
     90        } 
     91        return null; 
    10092    } 
    10193 
    102     // a simple echoString function 
     94    /* A simple echoString function. */ 
    10395    function echoStringSimple($inputString) 
    10496    { 
    105     return $inputString; 
     97        return $inputString; 
    10698    } 
    107      
    108     // an explicit echostring function 
     99 
     100    /* An explicit echoString function. */ 
    109101    function echoString($inputString) 
    110102    { 
    111     return new SOAP_Value('outputString','string',$inputString); 
     103        return new SOAP_Value('outputString', 'string', $inputString); 
    112104    } 
    113105 
    114106    function divide($dividend, $divisor) 
    115107    { 
    116         // the soap server would normally catch errors like this 
    117         // and return a fault, but this is how you do it yourself. 
    118         if ($divisor == 0) 
     108        /* The SOAP server would normally catch errors like this and return a 
     109         * fault, but this is how you do it yourself. */ 
     110        if ($divisor == 0) { 
    119111            return new SOAP_Fault('You cannot divide by zero', 'Client'); 
    120         else 
     112        } else { 
    121113            return $dividend / $divisor; 
     114        } 
    122115    } 
    123116 
     
    126119        return $inputStruct->__to_soap('outputStruct'); 
    127120    } 
    128      
     121 
    129122    /** 
    130      * echoStructAsSimpleTypes 
    131      * takes a SOAPStruct as input, and returns each of its elements 
    132      * as OUT parameters 
     123     * Takes a SOAPStruct as input, and returns each of its elements as OUT 
     124     * parameters. 
    133125     * 
    134      * this function is also aliased so you have to call it with 
    135      * echoStructAsSimpleTypes 
     126     * This function is also aliased so you have to call it as 
     127     * echoStructAsSimpleTypes. 
    136128     * 
    137129     * SOAPStruct is defined as: 
    138      * 
     130     * <code> 
    139131     * struct SOAPStruct: 
    140132     *    string varString 
    141133     *    integer varInt 
    142134     *    float varFloat 
    143      * 
     135     * </code> 
    144136     */ 
    145137    function myEchoStructAsSimpleTypes($struct) 
    146138    { 
    147     # convert a SOAPStruct to an array 
    148     return array( 
    149         new SOAP_Value('outputString','string',$struct->varString), 
    150         new SOAP_Value('outputInteger','int',$struct->varInt), 
    151         new SOAP_Value('outputFloat','float',$struct->varFloat) 
     139        /* Convert a SOAPStruct to an array. */ 
     140        return array( 
     141            new SOAP_Value('outputString', 'string', $struct->varString), 
     142            new SOAP_Value('outputInteger', 'int', $struct->varInt), 
     143            new SOAP_Value('outputFloat', 'float', $struct->varFloat) 
    152144        ); 
    153145    } 
    154      
     146 
    155147    function echoMimeAttachment($stuff) 
    156148    { 
    157         return new SOAP_Attachment('return','application/octet-stream',NULL,$stuff); 
    158     }     
     149        return new SOAP_Attachment('return', 
     150                                   'application/octet-stream', 
     151                                   null, 
     152                                   $stuff); 
     153    } 
     154 
    159155} 
    160  
    161 ?> 
Note: See TracChangeset for help on using the changeset viewer.