CWsdlGenerator

优质
小牛编辑
120浏览
2023-12-01
所有包 | 属性 | 方法
system.web.services
继承class CWsdlGenerator » CComponent
源自1.0
版本$Id: CWsdlGenerator.php 2799 2011-01-01 19:31:13Z qiang.xue $
源码framework/web/services/CWsdlGenerator.php
CWsdlGenerator是一个给定的服务类生成WSDL。

WSDL的生成是基于服务类文件中的文档注释。 特别是,它认识注释的‘@soap’标记it,并提取物API 方法和类型定义。

在服务类中,一个远程调用的方法必须是公共方法与doc 注释块包含‘@soap’标记。在文档注释,类型和名称 每一个输入参数和返回值的类型应使用 标准phpdoc格式。

CWsdlGenerator识别以下的原始类型(区分大小写) 参数和返回类型声明:
  • str/string:对应于xsd:string;
  • int/integer:对应于xsd:int;
  • float/double:对应于xsd:float;
  • bool/boolean:对应于xsd:boolean;
  • date:对应于xsd:date;
  • time:对应于xsd:time;
  • datetime:对应于xsd:dateTime;
  • array:对应于xsd:string;
  • object:对应于xsd:struct;
  • mixed:对应于xsd:anyType。


如果类型不是一个原始类型,它被认为是一个类类型, CWsdlGenerator将寻找其属性声明。只考虑公共属性, 它们各自关联到包含着‘@soap’标签的 doc注释块。doc注释块应该声明属性的类型。

CWsdlGenerator识别以下格式的数组类型:
typeName[]:对应于tns:typeNameArray


下面是声明一个远程调用方法的示例:
/ *** foo方法。* @param string 名字* @param string 值* @return string[] 一些数组* @soap* /
public function foo($name,$value) {...}


以下是声明一个类与远程访问的属性的例子:
class Foo {  / **    * @var string name of foo    * @soap    * /  public $name;  / **    * @var Member[] members of foo    * @soap    * /  public $members;
}
上面的‘members’属性是‘Member’对象的数组。由于‘Member’不是一个原始类型, CWsdlGenerator会重复查找,找出‘Member’的定义。

公共属性

隐藏继承属性

属性类型描述定义在
namespacestring用来生成WSDL的命名空间。 如果不设置, 默认为是生成的WSDL的类的名字。CWsdlGenerator
serviceNamestring生成的WSDL的名字。 如果不设置,默认为”urn:{$className}wsdl“。CWsdlGenerator

公共方法

隐藏继承方法

方法描述定义在
__call()如果类中没有调的方法名,则调用这个方法。CComponent
__get()返回一个属性值、一个事件处理程序列表或一个行为名称。CComponent
__isset()检查一个属性是否为null。CComponent
__set()设置一个组件的属性值。CComponent
__unset()设置一个组件的属性为null。CComponent
asa()返回这个名字的行为对象。CComponent
attachBehavior()附加一个行为到组件。CComponent
attachBehaviors()附加一个行为列表到组件。CComponent
attachEventHandler()为事件附加一个事件处理程序。CComponent
canGetProperty()确定属性是否可读。CComponent
canSetProperty()确定属性是否可写。CComponent
detachBehavior()从组件中分离一个行为。CComponent
detachBehaviors()从组件中分离所有行为。CComponent
detachEventHandler()分离一个存在的事件处理程序。CComponent
disableBehavior()禁用一个附加行为。CComponent
disableBehaviors()禁用组件附加的所有行为。CComponent
enableBehavior()启用一个附加行为。CComponent
enableBehaviors()启用组件附加的所有行为。CComponent
evaluateExpression()计算一个PHP表达式,或根据组件上下文执行回调。CComponent
generateWsdl()为指定的类生成WSDL。CWsdlGenerator
getEventHandlers()返回一个事件的附加处理程序列表。CComponent
hasEvent()确定一个事件是否定义。CComponent
hasEventHandler()检查事件是否有附加的处理程序。CComponent
hasProperty()确定属性是否被定义。CComponent
raiseEvent()发起一个事件。CComponent

属性详细

namespace 属性 public string $namespace;

用来生成WSDL的命名空间。 如果不设置, 默认为是生成的WSDL的类的名字。

serviceName 属性 public string $serviceName;

生成的WSDL的名字。 如果不设置,默认为”urn:{$className}wsdl“。

方法详细

generateWsdl() 方法
public string generateWsdl(string $className, string $serviceUrl, string $encoding='UTF-8')
$classNamestring类名字。
$serviceUrlstringWeb service的URL
$encodingstringWSDL的编码。默认为‘UTF-8’。
{return}string生成的WSDL
源码: framework/web/services/CWsdlGenerator.php#107 (显示) publicfunctiongenerateWsdl($className,$serviceUrl,$encoding='UTF-8')
{
$this->_operations=array();
$this->_types=array();
$this->_messages=array();
if($this->serviceName===null)
$this->serviceName=$className;
if($this->namespace===null)
$this->namespace="urn:{$className}wsdl";

$reflection=newReflectionClass($className);
foreach($reflection->getMethods()as$method)
{
if($method->isPublic())
$this->processMethod($method);
}

return$this->buildDOM($serviceUrl,$encoding)->saveXML();
}

为指定的类生成WSDL。