当前位置:网站首页>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
边栏推荐
- Technologists talk about open source: This is not just using love to generate electricity
- Visual Studio导入
- File contains vulnerability (I)
- 1037 Magic Coupon
- Opencv LBP features
- The Hong Kong Stock Exchange learned from US stocks and pushed spac: the follow-up of many PE companies could not hide the embarrassment of the world's worst stock market
- Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?
- How to change the IP address of computer mobile phone simulator
- Simply encapsulate JS and apply it
- “简单”的无限魔方
猜你喜欢
Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
Pytorch Basics
centos8安装mysql8.0.22教程
MySQL foundation --- query (learn MySQL foundation in 1 day)
Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?
Opencv LBP features
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Fabric. JS upload local image to canvas background
"Original, excellent and vulgar" in operation and maintenance work
随机推荐
kmp思想及模板代码
Small and medium-sized projects to achieve certification and authorization of hand filter
460. LFU cache bidirectional linked list
Typora installation (no need to enter serial number)
Operator details
Pytorch Basics
[paper translation] gcnet: non local networks meet squeeze exception networks and beyond
H5 jump applet
h5跳小程序
小程序跳装到公众号
With an amount of $50billion, amd completed the acquisition of Xilinx
Grbl software: basic knowledge of simple explanation
Financial portal related information
Fabric. JS round brush
Usage record of vector
Taskbar explicit / implicit toggle function
1037 Magic Coupon
软件测试基础篇
JVM class loading mechanism
idea开发工具常用的插件合集汇总