当前位置:Gxlcms > PHP教程 > SoapDiscoveryclassphp路虎discovery4ssdpdiscoverycancerdiscovery

SoapDiscoveryclassphp路虎discovery4ssdpdiscoverycancerdiscovery

时间:2021-07-01 10:21:17 帮助过:11人阅读

SoapDiscovery.class.php 源码如下:

============================================================

  1 php
  2  3/**
  4 * Copyright (c) 2005, Braulio Jos?Solano Rojas
  5 * All rights reserved.
  6 * 
  7 * Redistribution and use in source and binary forms, with or without modification, are
  8 * permitted provided that the following conditions are met:
  9 * 
 10 *     Redistributions of source code must retain the above copyright notice, this list of
 11 *     conditions and the following disclaimer. 
 12 *     Redistributions in binary form must reproduce the above copyright notice, this list of
 13 *     conditions and the following disclaimer in the documentation and/or other materials
 14 *     provided with the distribution. 
 15 *     Neither the name of the Solsoft de Costa Rica S.A. nor the names of its contributors may
 16 *     be used to endorse or promote products derived from this software without specific
 17 *     prior written permission.
 18 * 
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 20 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32 * 
 33 *
 34 * @version $Id$
 35 * @copyright 2005 
 36*/ 37 38/**
 39 * SoapDiscovery Class that provides Web Service Definition Language (WSDL).
 40 * 
 41 * @package SoapDiscovery
 42 * @author Braulio Jos?Solano Rojas
 43 * @copyright Copyright (c) 2005 Braulio Jos?Solano Rojas
 44 * @version $Id$
 45 * @access public
 46 **/ 47class SoapDiscovery {
 48private$class_name = '';
 49private$service_name = '';
 50 51/**
 52     * SoapDiscovery::__construct() SoapDiscovery class Constructor.
 53     * 
 54     * @param string $class_name
 55     * @param string $service_name
 56     **/ 57publicfunction __construct($class_name = '', $service_name = '') {
 58$this->class_name = $class_name;
 59$this->service_name = $service_name;
 60    }
 61 62/**
 63     * SoapDiscovery::getWSDL() Returns the WSDL of a class if the class is instantiable.
 64     * 
 65     * @return string
 66     **/ 67publicfunction getWSDL() {
 68if (empty($this->service_name)) {
 69thrownewException('No service name.');
 70        }
 71$headerWSDL = "\n";
 72$headerWSDL.= "$this->service_name\" targetNamespace=\"urn:$this->service_name\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:tns=\"urn:$this->service_name\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns=\"http://schemas.xmlsoap.org/wsdl/\">\n";
 73$headerWSDL.= "\n";
 74 75if (empty($this->class_name)) {
 76thrownewException('No class name.');
 77        }
 78 79$class = new ReflectionClass($this->class_name);
 80 81if (!$class->isInstantiable()) {
 82thrownewException('Class is not instantiable.');
 83        }
 84 85$methods = $class->getMethods();
 86 87$portTypeWSDL = '';
 88$bindingWSDL = '\n\n";
 89$serviceWSDL = '\n\n$this->service_name.'Port" binding="tns:'.$this->service_name."Binding\">$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF']."\" />\n\n\n";
 90$messageWSDL = '';
 91foreach ($methodsas$method) {
 92if ($method->isPublic() && !$method->isConstructor()) {
 93$portTypeWSDL.= '\n".'\n$method->getName()."Response\" />\n\n";
 94$bindingWSDL.= '\n".'\n$this->service_name\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n\n\n$this->service_name\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n\n\n";
 95$messageWSDL.= '\n";
 96$parameters = $method->getParameters();
 97foreach ($parametersas$parameter) {
 98$messageWSDL.= '\n";
 99                }
100$messageWSDL.= "\n";
101$messageWSDL.= '\n";
102$messageWSDL.= '\n";
103$messageWSDL.= "\n";
104            }
105        }
106$portTypeWSDL.= "\n";
107$bindingWSDL.= "\n";
108//return sprintf('%s%s%s%s%s%s', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, '');109110$fso = fopen($this->class_name . ".wsdl", "w");
111fwrite($fso, sprintf('%s%s%s%s%s%s', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, ''));
112    }
113114/**
115     * SoapDiscovery::getDiscovery() Returns discovery of WSDL.
116     * 
117     * @return string
118     **/119publicfunction getDiscovery() {
120return "\n\n$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF']."?wsdl\" />\n";
121    }
122}
123124 ?>

以上就介绍了SoapDiscoveryclassphp,包括了discovery方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行