Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of PHP5SOAP call and how to implement it?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you what the principle of PHP5SOAP call is and how to implement it. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

SOAP (SimpleObjectAccessProtocol) simple object access Protocol is a simple protocol for exchanging information in a distributed or distributed environment. It is a protocol based on XML. The following editor will explain the principles of PHP5SOAP calls and how to implement PHP5SOAP calls.

Principle of PHP5SOAP call

SOAP consists of four parts: SOAP envelop, which defines a framework that describes what is in a message, who sent it, who should accept and process it, and how to handle it; SOAP coding rules (encodingrules), which represent instances of the data types that applications need to use; and SOAPRPC representations (RPCrepresentation), which represent protocols for remote procedure calls and replies SOAP binding (binding), which uses the underlying protocol to exchange information.

WSDL (WebServiceDescriptionLanguage) is the standard XML format for describing XMLWeb services. WSDL is 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 independent of the specific language. As far as its definition is concerned, you can't think of WSDL as an object interface definition language. For example, application architectures such as CORBA or COM use the object interface definition language. WSDL remains protocol neutral, but it does have built-in support for binding SOAP, thus establishing an inextricable relationship 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 the two major standards of webservice, they are not necessarily related and can be used independently. The relationship between them is similar to that between HTTP and Html. The former is a protocol, while the latter is a description of an WebServer.

How to implement PHP5SOAP call

Configuration under PHP5

In the configuration file php.ini of php, find the

Extension=php_soap.dll

Then remove the previous; sign and restart the web service

Query webservice methods and parameters, data types

The incoming order interface of a provincial telecom company is http://***.******.com/services/AcceptedBusinesswsdl.

We use the _ _ geunctions () and _ _ getTypes () methods of SoapClient to 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

Header ("content-type:text/html;charset=utf-8")

Try {

$client=newSoapClient ("http://***.******.com/services/AcceptedBusinesswsdl");

Print_r ($client- > _ _ getFunctions ())

Print_r ($client- > _ _ getTypes ())

} catch (SOAPFault$e) {

Print$e

}

>

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

Array

(

[0] = > ArrayOf_xsd_anyTypeintroduceAcceptedBusiness (string$c3,string$c4,string$linkman,string$linknum,string$num,string$idcard,string$remark,string$address)

[1] = > ArrayOf_xsd_anyTypeintroduceAcceptedBusinessByAiZhuangWei (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] = > stringintroduceAcceptedBusinessByStandardInterface (string$xmlStr)

[3] = > stringintroduceAcceptedBusinessByCallOut (string$xmlStr)

[4] = > stringintroduceAcceptedBusinessByYddj (string$xmlParam)

[5] = > ArrayOf_xsd_anyTypequeryAcceptedBusinessByAiZhuangWei (string$surveycode,string$starttime,string$endtime)

[6] = > stringqueryCallOutOrderByConfig (string$xmlParam)

)

Array

(

[0] = > anyTypeArrayOf_xsd_anyType []

)

There is a method introduceAcceptedBusinessByStandardInterface (string$xmlStr), which will be the interface to be used as mentioned in the development documentation, with an argument of xml string

SoapHeader authentication is mentioned in other APIs, so you need to add the _ _ setSoapHeaders method. For more information, please see http://php.net/manual/zh/soapclient.setsoapheaders.php.

Submit the purchase order

This step is to concatenate the xml string according to the development document, and then pass it as a parameter to introduceAcceptedBusinessByStandardInterface

Create an acceptedbusiness.php, as follows

Header ("content-type:text/html;charset=utf-8")

Try {

$client=newSoapClient ('http://***.*******.com/services/AcceptedBusinesswsdl');

$xml= "

* * Telecom

Zhang San

13412341234

Shenzhen, Guangdong

IPhone6

1111111111111111111111111111111

2111

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

"

$return=$client- > introduceAcceptedBusinessByStandardInterface ($xml)

Print_r ($return)

} catch (SOAPFault$e) {

Print_r ('Exception:'.$e)

}

>

After execution in the browser, return to

0

The order is successful!

2014100905523549742

The above is what the principle of PHP5SOAP call is and how to implement it. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report