首先新建一个项目

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

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. mobilebone.js使用笔记

    mobilebone.js主要用来是网页呈现单页效果,添加类似native app的页面切换效果.原理是:当打开a链接里的页面时,不再以传统的新页面打开,而是以ajax-html的方式,将新页面的内容 ...

  2. python mysql desc

    #!/usr/bin/python import MySQLdb try: conn=MySQLdb.connect(host='localhost',user='root',passwd='your ...

  3. 注册表法修改IE8安全级别的方法

    最近写客户端工具修复IE浏览器的一些功能,下面是网上找到的东东 1.将当前用户IE安全级别设置为“中”: Windows Registry Editor Version 5.00 [HKEY_CURR ...

  4. AngularJS(一)

    什么是AngularJS[双向数据绑定:从界面的操作能实时反映到数据,数据的变更能实时展现到界面.]?1.AngularJS 使得开发现代的单一页面应用程序(SPAs:Single Page Appl ...

  5. BootStrap安装

    1. 安装Node.js    http://nodejs.org/download/ 2. 加速NPM安装    npm install -g cnpm --registry=http://r.cn ...

  6. [C#] zdbviewcs: 跨平台数据库查看器。支持SqlServer、Oracle、MySql等数据库

    作者:zyl910 一.说明 本工具有适合以下情况使用—— * 快速查看数据库中数据及表结构信息.* 测试ADO.Net下连接字符串的写法.* 帮忙分析ADO.Net数据库操作. 二.用法 运行本程序 ...

  7. IE11新文档模式Edge介绍与评估,及在WebBrowser应用中的使用。

    浏览器模式与文档模式概念是怎么来的? 1.浏览器模式与文档模式概念起源 为了解决兼容性的问题,在IE浏览器(IE8, IE9, IE10)中,引入了浏览器模式和文档模式两个概念,浏览网页时可以通过按F ...

  8. 用 Mahout 和 Elasticsearch 实现推荐系统

    原文地址 本文内容 软件 步骤 控制相关性 总结 参考资料 本文介绍如何用带 Apache Mahout 的 MapR Sandbox for Hadoop 和 Elasticsearch 搭建推荐引 ...

  9. MapReduce的一点理解

    对于MapReduce编程,大概率的流程用过的人或多或少都清楚,但是归结到细节上,就有的地方不清楚了,下面根据自己的疑问,加上从网上各处,找到的被人的描述,最自己的疑问做出回答. 1. MapRedu ...

  10. jQuery Mobile 移动开发中的日期插件Mobiscroll使用说明

    近期在移动方面的开发,使用jQuery Mobile ,移动方面的插件不如Web 方面的插件多,选择的更少,有一些需要自己去封装,但功力尚不足啊. 日期插件JQM也提供了内置的,但样式方面不好看,只好 ...