首先新建一个项目

在项目中新建下面这些文件

php类文件 test.php

<?php
class test {
public function __construct()
{
}
public function add($name,$age)
{
$result = array('REV'=>false);
$result['REV'] = true;
$result['DATA'] = 1;
$result = json_encode($result);
return $result;
}
public function del($id)
{
$result = false;
return $result;
}
public function getlist($type)
{
$result = array(
array('name'=>'张三','age'=>18),
array('name'=>'李四','age'=>20),
array('name'=>'jms','age'=>10),
array('name'=>'jk陈','age'=>8),
);
$result = json_encode($result);
return $result;
}
} ?>

使用zendstudio生成wsdl文件

 

生成的文件格式如下

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost/t/ws" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="test_server" targetNamespace="http://localhost/t/ws">
<wsdl:types>
<xsd:schema targetNamespace="http://localhost/t/ws">
<xsd:element name="getlist">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getlistResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getlistRequest">
<wsdl:part name="type" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="getlistResponse">
<wsdl:part name="resultRespose" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="test_server">
<wsdl:operation name="getlist">
<wsdl:input message="tns:getlistRequest"/>
<wsdl:output message="tns:getlistResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="test_serverSOAP" type="tns:test_server">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getlist">
<soap:operation
soapAction="http://localhost/t/ws/NewOperation" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="test_server">
<wsdl:port binding="tns:test_serverSOAP" name="test_serverSOAP">
<soap:address location="http://localhost/t/ws/server.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

调用server的文件 server.php

<?php
ini_set("soap.wsdl_cache_enabled", "0");  //测试时打开防止soap缓存
include("test.php");
$Server=new SoapServer('test_server.wsdl'); //SoapServer
$Server->setClass("test");
$Server->handle();
?>

测试调用webserver wsdl的文件

<?php
ini_set("soap.wsdl_cache_enabled", "0");
//$url = 'http://localhost/t/ws/test_server.wsdl';
$url = 'http://localhost/t/ws/server.php?wsdl'; //两种url都可以
$client = new SoapClient($url);
$params = array('type'=>1);
$res = $client->__soapCall('getlist',array('parameters'=>$params));
var_dump($res);
?>

返回数据:

string(119) "[{"name":"\u5f20\u4e09","age":18},{"name":"\u674e\u56db","age":20},{"name":"jms","age":10},{"name":"jk\u9648","age":8}]" 

调用成功

php 使用zendstudio 生成webservice文件 wsdl的更多相关文章

  1. C# 调用WebService的3种方式 :直接调用、根据wsdl生成webservice的.cs文件及生成dll调用、动态调用

    1.直接调用 已知webservice路径,则可以直接 添加服务引用--高级--添加web引用 直接输入webservice URL.这个比较常见也很简单 即有完整的webservice文件目录如下图 ...

  2. 根据wsdl文件生成webservice 的.cs文件 及 生成dll C#调用

               Visual Studio 2013->Visual Studio Tools->VS2013 开发人员命令提示 命令行输入 wsdl E:\WS.wsdl /out ...

  3. C#根据WSDL文件生成WebService服务端代码

    转自:http://www.cnblogs.com/liyi93/archive/2012/01/30/2332320.html 虽然现在已经进入了.NET FrameWork 4.0的时代,WebS ...

  4. 根据wsdl文件,Java工程自动生成webservice客户端调用

    根据wsdl文件,Java工程自动生成webservice客户端调用 1,工具:带有webservice插件的myeclips 2,步骤: (1),新建一个Java工程:relationship (2 ...

  5. 根据wsdl文件,soupUI生成webservice客户端代码

    根据wsdl文件,soupUI生成webservice客户端代码 功能介绍: 对于面向WebServie接口开发时,当我们已经获取到WSDL文件后,可以使用soapUI工具生成对应的客户端和服务端代码 ...

  6. 根据wsdl文件,Web工程自动生成webservice客户端调用

    根据wsdl文件,Web工程自动生成webservice客户端调用 1,工具:带有webservice插件的eclips 2,步骤: (1),新建一个Web工程:WSDLTest (2),浏览器访问W ...

  7. 根据wsdl文件生成WebService客户端代码

    有时候在项目中,一个项目可能有好几个公司在做.系统之间难免会出现互相调用接口的现象,这时候有一种办法就是使用webService.本篇文章将介绍如何将对接系统提供的WebService接口,根据对方提 ...

  8. 解析利用wsdl.exe生成webservice代理类的详解

    利用wsdl.exe生成webservice代理类:根据提供的wsdl生成webservice代理类1.开始->程序->Visual Studio 2005 命令提示2.输入如下红色标记部 ...

  9. So easy Webservice 5.WSDL 文件说明

    WSDL – WebService Description Language – Web服务描述语言 通过XML形式说明服务在什么地方-地址. 通过XML形式说明服务提供什么样的方法 – 如何调用. ...

随机推荐

  1. 苹果App Store审核指南中文翻译(2014.9.1更新)

    转:http://www.cocoachina.com/appstore/20140901/9500.html CocoaChina对<苹果应用商店审核指南>中文翻译最近一次更新时间为20 ...

  2. Leetcode 160 Intersection of Two Linked Lists 单向链表

    找出链表的交点, 如图所示的c1, 如果没有相交返回null. A:             a1 → a2                               ↘               ...

  3. python连接数据库

    使用pymysql://安装pymysqlpip install pymysql 代码: # coding=utf8 import pymysql # 创建连接对象 conn = pymysql.co ...

  4. Memcached常规应用与分布式部署方案

    1.Memcached常规应用 $mc = new Memcache(); $mc->conncet('127.0.0.1', 11211); $sql = sprintf("SELE ...

  5. APP顶号逻辑

    登录的接口login.do接口上需要记录关键的信息:userId.设备型号(Android|iPhone).登录时间.登录IP.设备唯一标识(UUID) 当在另外一台新设备上登录同一帐号时,将user ...

  6. Distributed Result Grouping Caveats

    Distributed Result Grouping Caveats Grouping is supported distributed searches, with some caveats: 1 ...

  7. 【linux】修改文件所属用户和组

    使用chown命令可以修改文件或目录所属的用户: 命令:chown 用户 目录或文件名 例如:chown qq /home/qq  (把home目录下的qq目录的拥有者改为qq用户) 使用chgrp命 ...

  8. ASP.NET MVC验证标注的扩展-checkbox必选

    我们知道ASP.NET mvc提供一些表单的验证标注,比如必填属性RequiredAttribute 但是这个属性不适合选择框的必选 但是很多时候,我们却是需要一些必选的单选框 比如网站注册的时候,需 ...

  9. PMBOK/CMM/CMMI/OPM3

    1968年为了解决大型软件项目的软件危机,北大西洋公约组织(NATO)提出了“软件工程”这一术语,以改进软件开发设计过程. 1969年美国项目管理协会(PMI)组织成立,从1981年起经过30年的努力 ...

  10. Linux连续执行多条命令

    引自:这里 每条命令使用";"隔开,则无论前边的命令执行成功与否都会继续执行下一条命令这里,故意将第二条命令中的echo多写了一个o,命令执行出错,但并不影响后续命令的执行可以这么 ...