search
HomeBackend DevelopmentPHP TutorialWSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial

The implementation process of WSDL and SOAP calls under PHP5, php5wsdl

1. Basic concepts

SOAP (Simple Object Access Protocol) Simple Object Access Protocol is a simple protocol for exchanging information in a decentralized or distributed environment. It is an XML-based protocol. It includes four parts: SOAP envelop (envelop), encapsulation Defines a framework that describes what is in the message, who sent it, who should accept and process it and how to process them; SOAP encoding rules (encoding rules), which are used to represent instances of the data types that the application needs to use; SOAP RPC representation represents the protocol for remote procedure calls and responses; SOAP binding uses the underlying protocol to exchange information.

WSDL (Web Service Description Language) is the standard XML format for describing XML Web services. WSDL was proposed by developers such as Ariba, Intel, IBM and Microsoft. It defines the relevant operations and messages sent and received by a given Web service in an abstract way that is independent of the specific language. By its definition, you cannot yet think of WSDL as an object interface definition language. For example, application architectures such as CORBA or COM will use object interface definition languages. WSDL remains protocol neutral, but it does have built-in support for binding to SOAP, thus establishing an inseparable link with SOAP. So, when I discuss WSDL in this article, I will assume that you use SOAP as your communication protocol.

Although SOAP and WSDL are two major standards for web services, they are not necessarily connected and can be used independently. The relationship between them is similar to the relationship between HTTP and Html. The former is a protocol, and the latter is a description of a Web Server.


2. Configuration under PHP5

In the php configuration file php.ini, find

extension=php_soap.dll

Then remove the “;” sign in front, and then restart the web service

3. Query web service methods, parameters, and data types

The order entry interface of a provincial telecommunications company is http://***.******.com/services/AcceptedBusiness?wsdl
We use SoapClient’s __geunctions() and __getTypes() Method View the methods, parameters and data types of the interface
Only the interfaces listed in __getFunctions can be called by soap.
Create the code soap.php in the root directory

WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial
<?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;
}
?>
WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial

After running: http://localhost/soap.php in the browser, the return result is as follows

WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial
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 <strong>introduceAcceptedBusinessByStandardInterface</strong>(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[]
)
WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial

There is a method introduceAcceptedBusinessByStandardInterface(string $xmlStr), which will be the interface to be used mentioned in the development document, and the parameter is an xml string

In addition, some interfaces mention SoapHeader authentication, which requires adding the __setSoapHeaders method. For details, see http://php.net/manual/zh/soapclient.setsoapheaders.php


4. Submit order

This step is to splice the xml string according to the development document, and then pass it in as a parameter of introduceAcceptedBusinessByStandardInterface
Create acceptedbusiness.php with the following content

WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial
<?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>**电信</C3>
      <C4></C4>
      <LINKMAN>张三</LINKMAN>
      <LINKNUM>13412341234</LINKNUM>
      <LINKADDRESS>广东深圳</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);
}
?>
WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial

After executing in the browser, return

WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial
<?xml version="1.0" encoding="UTF-8"?>
<PACKAGE>
    <STATUS>0</STATUS>
    <REASON>入单成功!</REASON>
    <ORDERSEQ>2014100905523549742</ORDERSEQ>
</PACKAGE>
WSDL, SOAP call implementation process under PHP5, php5wsdl_PHP tutorial ​ ​

Reference: http://www.cnblogs.com/txw1958/p/php5-soap-wsdl.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/966284.htmlTechArticleWSDL, SOAP call implementation process under PHP5, php5wsdl 1. Basic concept SOAP (Simple Object Access Protocol) simple object access A protocol is a simple way to exchange information in a decentralized or distributed environment...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php5和php8有什么区别php5和php8有什么区别Sep 25, 2023 pm 01:34 PM

php5和php8的区别在性能、语言结构、类型系统、错误处理、异步编程、标准库函数和安全性等方面。详细介绍:1、性能提升,PHP8相对于PHP5来说在性能方面有了巨大的提升,PHP8引入了JIT编译器,可以对一些高频执行的代码进行编译和优化,从而提高运行速度;2、语言结构改进,PHP8引入了一些新的语言结构和功能,PHP8支持命名参数,允许开发者通过参数名而不是参数顺序等等。

如何使用PHP和SOAP实现Web服务的调用和开发如何使用PHP和SOAP实现Web服务的调用和开发Jun 25, 2023 am 09:59 AM

在Web开发领域中,Web服务是一种非常重要的技术,它可以使不同的应用程序之间互相通信,从而构建更加复杂和强大的系统。在本文中,我们将深入探讨如何使用PHP和SOAP实现Web服务的调用和开发。SOAP(SimpleObjectAccessProtocol)是一种基于XML的协议,它用于在不同的应用程序之间进行信息交换。SOAP是一个重要的Web服务标

PHP和SOAP:如何实现远程过程调用(RPC)PHP和SOAP:如何实现远程过程调用(RPC)Jul 29, 2023 pm 02:45 PM

PHP和SOAP:如何实现远程过程调用(RPC)简介:近年来,随着分布式系统的兴起,远程过程调用(RemoteProcedureCall,RPC)在Web开发中被广泛采用。本文将介绍如何使用PHP和SOAP实现RPC,以及通过代码示例演示其用法。一、什么是远程过程调用(RPC)?远程过程调用(RemoteProcedureCall,RPC)是一种通信

PHP和SOAP:如何实现数据的同步和异步处理PHP和SOAP:如何实现数据的同步和异步处理Jul 28, 2023 pm 03:29 PM

PHP和SOAP:如何实现数据的同步和异步处理引言:在现代Web应用程序中,数据的同步和异步处理变得越来越重要。同步处理指的是一次只处理一个请求,并等待该请求完成后再处理下一个请求;而异步处理则是同时处理多个请求,并不等待某个请求的完成。在本文中,我们将介绍如何使用PHP和SOAP来实现数据的同步和异步处理。一、SOAP简介SOAP(SimpleObjec

php5如何改80端口php5如何改80端口Jul 24, 2023 pm 04:57 PM

php5改80端口的方法:1、编辑Apache服务器的配置文件中的端口号;2、辑PHP的配置文件以确保PHP在新端口上工作;3、重启Apache服务器,PHP应用程序将开始在新的端口上运行。

PHP中的SOAP协议指南PHP中的SOAP协议指南May 20, 2023 pm 07:10 PM

随着互联网技术的不断发展,越来越多的企业级应用需要向其它应用程序提供接口以实现数据和业务的交互。在这种情况下,我们需要一种可靠的协议来传输数据并确保数据的完整性和安全性。SOAP(SimpleObjectAccessProtocol)就是一种基于XML的协议,可用于在Web环境中实现应用之间的通信。而PHP作为一种流行的Web编程语言,

如何使用PHP和SOAP实现数据的压缩和解压缩如何使用PHP和SOAP实现数据的压缩和解压缩Jul 29, 2023 pm 12:28 PM

如何使用PHP和SOAP实现数据的压缩和解压缩导言:在现代互联网应用中,数据的传输是非常常见的操作,然而,随着互联网应用的不断发展,数据量的增加和传输速度的要求,合理地使用数据压缩和解压缩技术成为了一个非常重要的话题。在PHP开发中,我们可以使用SOAP(SimpleObjectAccessProtocol)协议来实现数据的压缩和解压缩。本文将介绍如何

如何使用PHP和SOAP实现Web服务的部署和发布如何使用PHP和SOAP实现Web服务的部署和发布Jul 28, 2023 pm 01:57 PM

如何使用PHP和SOAP实现Web服务的部署和发布引言:在当今互联网时代,Web服务的部署和发布成为了一个非常重要的话题。PHP是一种流行的服务器端编程语言,而SOAP(SimpleObjectAccessProtocol)是一种XML协议,用于在Web服务之间进行通信。本文将向您介绍如何使用PHP和SOAP实现Web服务的部署和发布,并提供一些代码示

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software