当前位置:网站首页>Implementation process of WSDL and soap calls under PHP5
Implementation process of WSDL and soap calls under PHP5
2022-07-05 13:56:00 【Brother Xing plays with the clouds】
One 、 Basic concepts
SOAP(Simple Object Access Protocol ) Simple object access protocols are decentralized or Distributed A simple protocol for exchanging information in the environment of , It's based on XML The agreement , It has four parts :SOAP encapsulation (envelop), Encapsulation definition A description of what is in the message , Who sent it , Who should accept and deal with it and how to deal with them ;SOAP Encoding rules (encoding rules), An instance that represents the data type that the application needs to use ; SOAP RPC Express (RPC representation), Represents the protocol for remote procedure calls and replies ;SOAP binding (binding), Exchange information using underlying protocols .
WSDL(Web Service Description Language) It's just a description XML Web Standards of service XML Format ,WSDL from Ariba、Intel、IBM And Microsoft and other developers . It defines a given... In an abstract way independent of the concrete language Web Service receiving and sending Related operations and messages . By definition , You can't put WSDL As an object interface definition language , for example ,CORBA or COM Such as application architecture will use object interface definition language . WSDL Keep the agreement neutral , But it does have bindings built in SOAP Support for , Thus the same as SOAP Established an inseparable connection . therefore , When I discuss in this article WSDL When , I'll assume you hold SOAP As your communication protocol .
SOAP and WSDL Although it is web service Two standards of , But there is no necessary connection between the two , Can be used independently . The relationship between them is similar HTTP and Html The relationship between . The former is an agreement , The latter is for a Web Server Description of .
Two 、PHP5 Configuration below
stay php The configuration file for php.ini in , find
extension=php_soap.dll
And then, you can put the ; Remove the number , And then restart web service
3、 ... and 、 Inquire about web service Methods and parameters 、 data type
The inbound interface of a provincial telecom company is http://***.******.com/services/AcceptedBusiness?wsdl We use SoapClient Of __geunctions() and __getTypes() Method to view the methods of the interface , Parameters and data types Only __getFunctions The interfaces listed in can be soap call . Create code under the root directory soap.php
<?php
header("content-type:text/html;charset=utf-8");
try {
$client = new SoapClient("http://***.******.com/services/AcceptedBusiness?wsdl");
print_r($client->__getFunctions());
print_r($client->__getTypes());
} catch (SOAPFault $e) {
print $e;
}
?>
Run in browser :http://localhost/soap.php after , The results are as follows
Array
(
[0] => ArrayOf_xsd_anyType introduceAcceptedBusiness(string $c3, string $c4, string $linkman, string $linknum, string $num, string $idcard, string $remark, string $address)
[1] => ArrayOf_xsd_anyType introduceAcceptedBusinessByAiZhuangWei(string $subname, string $linkphone, string $idcard, string $address, string $businesstype, string $marketcode, string $surveycode, string $commanager, string $commanagerphone, string $bendiwang, string $fenju, string $zhiju, string $remark)
[2] => string introduceAcceptedBusinessByStandardInterface(string $xmlStr)
[3] => string introduceAcceptedBusinessByCallOut(string $xmlStr)
[4] => string introduceAcceptedBusinessByYddj(string $xmlParam)
[5] => ArrayOf_xsd_anyType queryAcceptedBusinessByAiZhuangWei(string $surveycode, string $starttime, string $endtime)
[6] => string queryCallOutOrderByConfig(string $xmlParam)
)
Array
(
[0] => anyType ArrayOf_xsd_anyType[]
)
There's a way introduceAcceptedBusinessByStandardInterface(string $xmlStr), It will be the interface to be used mentioned in the development document , Parameter is xml character string
In addition, some interfaces mention SoapHeader authentication , It's about joining __setSoapHeaders Method , Details can be viewed http://php.net/manual/zh/soapclient.setsoapheaders.php
Four 、 Submit the receipt
This step is to splice according to the development documents xml character string , And then as a introduceAcceptedBusinessByStandardInterface Parameters passed in establish acceptedbusiness.php, The contents are as follows
<?php
header("content-type:text/html;charset=utf-8");
try {
$client = new SoapClient('http://***.*******.com/services/AcceptedBusiness?wsdl');
$xml = "
<?xml version='1.0' encoding='UTF-8' ?>
<PACKAGE>
<C3>** telecom </C3>
<C4></C4>
<LINKMAN> Zhang San </LINKMAN>
<LINKNUM>13412341234</LINKNUM>
<LINKADDRESS> Guangdong shenzhen </LINKADDRESS>
<REMARK>iPhone 6</REMARK>
<CHANNEL></CHANNEL>
<GRIDCODE>1111111111111111111111111111111</GRIDCODE>
<AGENTCODE>2111</AGENTCODE>
<KEY>1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</KEY>
</PACKAGE>
";
$return = $client->introduceAcceptedBusinessByStandardInterface($xml);
print_r($return);
} catch (SOAPFault $e) {
print_r('Exception:'.$e);
}
?>
After execution in the browser , return
<?xml version="1.0" encoding="UTF-8"?>
<PACKAGE>
<STATUS>0</STATUS>
<REASON> Order entry succeeded !</REASON>
<ORDERSEQ>2014100905523549742</ORDERSEQ>
</PACKAGE>
边栏推荐
- PHP character capture notes 2020-09-14
- Solution to the prompt of could not close zip file during phpword use
- 明峰医疗冲刺科创板:年营收3.5亿元 拟募资6.24亿
- Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
- 搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
- JS takes key and value from an array object to form a new object
- Requests + BS4 crawl Douban top250 movie information
- Jetpack Compose入门到精通
- Assembly language - Beginner's introduction
- OSI and tcp/ip protocol cluster
猜你喜欢
金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
Elfk deployment
Embedded software architecture design - message interaction
Wonderful express | Tencent cloud database June issue
荐号 | 有趣的人都在看什么?
几款分布式数据库的对比
zabbix 监控
国富氢能冲刺科创板:拟募资20亿 应收账款3.6亿超营收
Summit review | baowanda - an integrated data security protection system driven by compliance and security
Godson 2nd generation burn PMON and reload system
随机推荐
Requset + BS4 crawling shell listings
PHP basic syntax
PostgreSQL Usage Summary (PIT)
matlab学习2022.7.4
PHP generate Poster
Simple PHP paging implementation
Network security - Novice introduction
Selenium crawls Baidu pictures
Sqllab 1-6 exercise
深拷贝真难
【华南理工大学】考研初试复试资料分享
昆仑太科冲刺科创板:年营收1.3亿拟募资5亿 电科太极持股40%
ELK 企业级日志分析系统
Data Lake (VII): Iceberg concept and review what is a data Lake
广发期货排名多少?网上办理广发期货开户安全可靠吗?
Aspx simple user login
Blue Bridge Cup study 2022.7.5 (morning)
如何把大的‘tar‘存档文件分割成特定大小的多个文件
:: ffff:192.168.31.101 what address is it?
leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)