当前位置:网站首页>PHP 开发与测试 Webservice(SOAP)-Win
PHP 开发与测试 Webservice(SOAP)-Win
2022-07-02 05:47:00 【杰儿__er】
WebService是一种跨编程语言和跨操作系统平台的远程调用技术。
> 环境搭建
1.phpStudy链接:https://pan.baidu.com/s/1Uk5Cq28tSXBkolgmSarYnw?pwd=x2b8
2.phpStudy提取码:x2b8
> 理解webservice
1.从表面上看,WebService就是一个应用程序向外界暴露出一个能通过Web进行调用的API,也就是说能用编程的方法通过Web来调用这个应用程序。我们把调用这个WebService的应用程序叫做客户端,而把提供这个WebService的应用程序叫做服务端。
2.从深层次看,WebService是建立可互操作的分布式应用程序的新平台,是一个平台,是一套标准。它定义了应用程序如何在Web上实现互操作性,你可以用任何你喜欢的语言,在任何你喜欢的平台上写Web service ,只要我们可以通过Web service标准对这些服务进行查询和访问。
3.Web Service是一个平台独立的,低耦合的,自包含的、基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述、发布、发现、协调和配置这些应用程序,用于开发分布式的交互操作的应用程序。 [1]
4.Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的、专门的第三方软件或硬件, 就可相互交换数据或集成。依据Web Service规范实施的应用之间, 无论它们所使用的语言、 平台或内部协议是什么, 都可以相互交换数据。Web Service是自描述、 自包含的可用网络模块, 可以执行具体的业务功能。Web Service也很容易部署, 因为它们基于一些常规的产业标准以及已有的一些技术,诸如标准通用标记语言下的子集XML、HTTP。Web Service减少了应用接口的花费。Web Service为整个企业甚至多个组织之间的业务流程的集成提供了一个通用机制。
> Web服务的三个核心
1、Soap:
SOAP(Simple Object Access Protocol,简单对象访问协议)是一个基于xml的协议,用于在分步的应用程序都可以识别。另外,SOAP本身没有定义任何程序语言,这使得SOAP能够以消息的形式传递到各种远程系统中。SOAP所使用的传输协议,可以是HTTP,SMTP,POP3,JMS。
SOAP包括了4部分:
01.“SOAP封装(Envelope)”:
定义一个描述信息描述的内容是什么,是谁发送的,谁应当处理他,以及如何处理他们的框架。02.“SOAP编码规则”:
用于表示应用程序需要使用的数据类型的实例。03.“SOAP RPC":
表示远程过程中调用和应答的协定。04.“SOPA绑定”:
使用底层协议交换信息。2.WSDL:
WSDL(Web Service Description Language,web服务描述语言)是一个XML文档,他以一种和具体语言无关的抽象方式定义了给定web服务收发者的有关操作和消息。3.UDDI:
UDDI(Universal Description Discovery and Integration,统一描述发现和集成协议)是一个规范,定义了与web服务相关的信息的发布,发现和管理。
Web Service 实例
在根目录下创建soap文件夹,文件结构如下:
Client.php
<?php
try{
// non-wsdl方式调用web service
// 创建 SoapClient 对象
$soap = new SoapClient(null,array('location'=>"http://localhost/soap/Server.php",'uri'=>'Server.php'));
// 调用函数
$result1 = $soap->getName();
$result2 = $soap->__soapCall("getUrl",array());
echo $result1."<br/>";
echo $result2;
} catch(SoapFault $e){
echo $e->getMessage();
}catch(Exception $e){
echo $e->getMessage();
}
Server.php
<?php
// SiteInfo 类用于处理请求
Class SiteInfo
{
/**
* 返回网站名称
* @return string
*
*/
public function getName(){
return "菜鸟教程-test";
}
public function getUrl(){
return "www.runoob.com";
}
}
// 创建 SoapServer 对象
$s = new SoapServer(null,array("location"=>"http://localhost/soap/Server.php","uri"=>"Server.php"));
// 导出 SiteInfo 类中的全部函数
$s->setClass("SiteInfo");
// 处理一个SOAP请求,调用必要的功能,并发送回一个响应。
$s->handle();
?>
测试webservice实例
打开浏览器输入:http://localhost/soap/Client.php
参考连接:
http://47.106.68.247/ycsyth/webservices/ycsbizService?wsdl
https://blog.csdn.net/qq_33196814/article/details/122303882
https://www.cnblogs.com/guanfuchang/p/5985070.html
边栏推荐
- Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
- Reflection of the soul of the frame (important knowledge)
- 记录sentry的踩坑之路
- Zzuli:1060 numbers in reverse order
- Fabric. JS right click menu
- 460. LFU 缓存 双向链表
- [Chongqing Guangdong education] selected reading reference materials of British and American literature of Nanyang Normal University
- Gee series: unit 8 time series analysis in Google Earth engine [time series]
- [leetcode] day92 container with the most water
- Pytorch Chinese document
猜你喜欢

OLED12864 液晶屏

Oled12864 LCD screen

kmp思想及模板代码

《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记

Principle and implementation of parallax effect

How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure

mysql的约束总结

"Original, excellent and vulgar" in operation and maintenance work

Centos8 installation mysql8.0.22 tutorial

MySQL foundation --- query (learn MySQL foundation in 1 day)
随机推荐
软件测试答疑篇
Record sentry's path of stepping on the pit
[golang syntax] be careful with the copy of slices
软件测试 - 概念篇
测试 - 用例篇
软件测试基础篇
[leetcode] day92 container with the most water
Ls1046nfs mount file system
Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond
Importation de studio visuel
3D 打印机 G 代码命令:完整列表和教程
Gee series: unit 8 time series analysis in Google Earth engine [time series]
c语言中的几个关键字
Detailed explanation of Pointer use
小程序跳装到公众号
【LeetCode】Day92-盛最多水的容器
How to change the IP address of computer mobile phone simulator
all3dp.com网站中全部Arduino项目(2022.7.1)
Zzuli:1061 sequential output of digits
File contains vulnerability (I)