文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Zend Studio for Eclipse 从PHP类生成WSDL文件

Zend Studio for Eclipse 从PHP类生成WSDL文件

时间:2010-06-04  来源:windlike

Zend Studio for Eclipse生成WSDL文件的方式是依赖于PHP文档注释的.它依赖与方法的PHP doc注释来生成合适的方法的参数数据类型.生成的WSDL仅包含PHP类文件中的公共(public)方法

菜单工具条,File->Export->PHP->WSDL文件
或则在PHP Explorer视图中,右击PHP文件,选择Export->PHP->WSDLFIle

生成 WSDL 文件对话框,输入要生成的WSDL文件名,保存路径,选择目标PHP类

设置名称空间,Binding选项,消息编码样式

配置摘要

WSDL文件的GEF图

这样,WSDL文件的生成作为一个配置集保存.

Class: Passport.php

class Passport {

const E_USERNAME_INVALID = 1;

public $username;
public $passwd;
public $emai;
public $verifycode;

/**
* user register service
*
* @param string $username
* @param string $passwd
* @param string $email
* @param string $verifycode
*
* @return boolean
*/
public function register($username, $passwd, $email, $verifycode){
// here is register code
return $username. "\n" .
$passwd . "\n" .
$email . "\n" .
$verifycode;
}
}

WSDL: PassportSerivice.wsdl

<?xml version='1.0' encoding='UTF-8'?>
<!-- WSDL file generated by Zend Studio. -->
<definitions name="Passport" targetNamespace="urn:Passport"
xmlns:typens="urn:Passport"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="register">
<part name="username" type="xsd:string"/>
<part name="passwd" type="xsd:string"/>
<part name="email" type="xsd:string"/>
<part name="verifycode" type="xsd:string"/>
</message>
<message name="registerResponse">
<part name="registerReturn" type="xsd:string"/>
</message>
<portType name="PassportPortType">
<operation name="register">
<documentation>
Enter description here...
</documentation>
<input message="typens:register"/>
<output message="typens:registerResponse"/>
</operation>
</portType>
<binding name="PassportBinding" type="typens:PassportPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="register">
<soap:operation soapAction="urn:PassportAction"/>
<input>
<soap:body namespace="urn:Passport" use="literal"/>
</input>
<output>
<soap:body namespace="urn:Passport" use="literal"/>
</output>
</operation>
</binding>
<service name="PassportService">
<port name="PassportPort" binding="typens:PassportBinding">
<soap:address location="http://home/webservices/soap/new_passport/server.php"/>
</port>
</service>
</definitions>
服务器端:server.php
<?php
require_once 'Passport.php';
$server = new SoapServer(
"http://home/webservices/soap/new_passport/PassportService.wsdl"
,array(
'encoding'=>'utf-8',
'soap_version' => SOAP_1_2,
'uri' => 'Passport',
'style' => SOAP_RPC,
'use' => SOAP_LITERAL)
);
$server->setClass('Passport');
$server->handle();
?>
客户端: client.php
<?php
$client = new SoapClient("http://home/webservices/soap/new_passport/PassportService.wsdl",
array(
"trace"=>1,
"exceptions"=>0,
"soap_version" => SOAP_1_2
)
);
$result = $client->register('hezhiqiang','loveit','[email protected]','H6mSkD');
var_dump($result);
?>
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载