wsdl example
<?xml version =<span>'<span>1.0</span><span>'</span> encoding =<span>'</span><span>UTF-8</span><span>'</span> ?> definitions targetNamespace=<span>'</span><span>http://localhost/00/</span><span>'</span><span> xmlns:tns</span>=<span>'</span><span>http://localhost/00/</span><span>'</span><span> xmlns:soap</span>=<span>'</span><span>http://schemas.xmlsoap.org/wsdl/soap/</span><span>'</span><span> xmlns:xsd</span>=<span>'</span><span>http://www.w3.org/2001/XMLSchema</span><span>'</span><span> xmlns:soapenc</span>=<span>'</span><span>http://schemas.xmlsoap.org/soap/encoding/</span><span>'</span><span> xmlns:wsdl</span>=<span>'</span><span>http://schemas.xmlsoap.org/wsdl/</span><span>'</span><span> xmlns</span>=<span>'</span><span>http://schemas.xmlsoap.org/wsdl/</span><span>'</span>> <!--<types> 元素定义 web service 使用的数据类型,WSDL 使用 XML Schema 语法来定义数据类型,也可以自定义Schema不包含的类型--> <types> <schema xmlns:xsd="<span">"<span>http://www.w3.org/2001/XMLSchema</span><span>"</span><span> targetNamespace</span>=<span>"</span><span>http://localhost/00/</span><span>"</span>> </schema> </types> <!-- <message><span> 元素可定义每个消息的部件,以及相关联的数据类型. </span>--> <message name="<span">'<span>testRequest</span><span>'</span>> <part name="<span">"<span>term</span><span>"</span> type=<span>"</span><span>xsd:string</span><span>"</span>/> </part></message> <message name="<span">'<span>testResponse</span><span>'</span>> <part name="<span">"<span>value</span><span>"</span> type=<span>"</span><span>xsd:string</span><span>"</span>/> </part></message> <!-- <portType><span> 元素是最重要的 WSDL 元素.它可描述一个 web service、可被执行的操作,以及相关的消息. 它告诉你去哪个WebService的连接点,扮演了一个控制者. </span>--> <porttype name="<span">'<span>oplist</span><span>'</span>> <operation name="<span">'<span>test</span><span>'</span>> <input message="<span">'<span>tns:testRequest</span><span>'</span>/> <output message="<span">'<span>tns:testResponse</span><span>'</span>/> </output></operation> </porttype> <!--<binding> 元素为每个端口定义消息格式和协议细节--> <binding name="<span">'<span>cartSoap</span><span>'</span> type=<span>'</span><span>tns:oplist</span><span>'</span>> <!--style:属性可取值 <span>"</span><span>rpc</span><span>"</span> 或 <span>"</span><span>document</span><span>"</span>,ransport:属性定义了要使用的 SOAP 协议.在这个例子中我们使用 HTTP--> <binding style="<span">'<span>rpc</span><span>'</span><span> transport</span>=<span>'</span><span>http://schemas.xmlsoap.org/soap/http</span><span>'</span>/> <!--operation 元素定义了每个端口提供的操作符,对于每个操作,相应的 SOAP 行为都需要被定义--> <operation name="<span">'<span>test</span><span>'</span>> <operation soapaction="<span">'<span>http://www.cwtservice.cn/newOperation/</span><span>'</span>/> <input> <body use="<span">'<span>encoded</span><span>'</span> <span>namespace</span>=<span>'</span><span>urn:xmethods-delayed-quotes</span><span>'</span><span> encodingStyle</span>=<span>'</span><span>http://schemas.xmlsoap.org/soap/encoding/</span><span>'</span>/> <output> <body use="<span">'<span>encoded</span><span>'</span> <span>namespace</span>=<span>'</span><span>urn:xmethods-delayed-quotes</span><span>'</span><span> encodingStyle</span>=<span>'</span><span>http://schemas.xmlsoap.org/soap/encoding/</span><span>'</span>/> </body></output> </body></operation></operation> </binding></binding> <!--<service>包含一个或者多个port元素,每个port元素表示一个不同的Web服务--> <service name="<span">'<span>shopWS</span><span>'</span>> <port name="<span">'<span>cartSoap</span><span>'</span> binding=<span>'</span><span>tns:cartSoap</span><span>'</span>> <address location="<span">'<span>http://localhost/00/wss.php</span><span>'</span>/> </address></port> </service>
Server side example:
<span>function test($x) { </span><span>return</span><span> $x; } $ss </span>= <span>new</span> SoapServer(<span>'</span><span>http://localhost/00/wsdl.xml</span><span>'</span><span>); $ss</span>->addFunction(<span>'</span><span>test</span><span>'</span><span>); $ss</span>->handle();
Client call:
$soap = <span>new</span> soapClient(<span>'</span><span>http://localhost/00/wsdl.xml</span><span>'</span>,array(<span>'</span><span>trace</span><span>'</span>=><span>true</span><span>)); var_dump($soap</span>->test(<span>'</span><span>10086</span><span>'</span>));
Passing and returning array parameters
If the parameters passed or returned are arrays, you can explain them in the message tag.
<message name="<span">'<span>testRequest</span><span>'</span>> <part name="<span">"<span>term</span><span>"</span> type=<span>"</span><span>xsd:ArrayOfString</span><span>"</span>/> </part></message> <message name="<span">'<span>testResponse</span><span>'</span>> <part name="<span">"<span>value</span><span>"</span> type=<span>"</span><span>xsd:ArrayOfString</span><span>"</span>/> </part></message>
XML-RPC call
XML-<span>RPC可以理解为简化版的soap,对数据的包装相对简洁. php.ini中,要打开extension</span>=php_xmlrpc.dll
<span>/*</span><span> 求和函数 注意,rpc服务器在调用函数时,传的参数是这样的: array(0=>'函数名' , 1=>array(实参1,实参2,...实参N) , 2=>NULL) </span><span>*/</span><span> function hello() { </span><span>return</span> <span>'</span><span>hello</span><span>'</span><span>; } function sum($method , $args , $extra) { </span><span>return</span><span> array_sum($args); } </span><span>//</span><span> 创建RPC Server</span> $server =<span> xmlrpc_server_create (); xmlrpc_server_register_method ($server , </span><span>'</span><span>hello</span><span>'</span> , <span>'</span><span>hello</span><span>'</span><span>); xmlrpc_server_register_method ($server , </span><span>'</span><span>sum</span><span>'</span> , <span>'</span><span>sum</span><span>'</span><span>); </span><span>//</span><span> 收取请求</span> $request =<span> $HTTP_RAW_POST_DATA; </span><span>//</span><span>执行调用客户端的XML请求后获取执行结果</span> $xmlrpc_response = xmlrpc_server_call_method($server, $request , <span>null</span><span>); </span><span>//</span><span>把函数处理后的结果XML进行输出</span> header(<span>'</span><span>Content-Type: text/xml</span><span>'</span><span>); echo $xmlrpc_response; </span><span>//</span><span>销毁XML-RPC服务器端资源</span> xmlrpc_server_destroy($server);
Client:
<span>class</span><span> rpcclient { </span><span>protected</span><span> $url; </span><span>public</span> function __construct($url=<span>''</span><span> ) { $</span><span>this</span>->url =<span> $url; } </span><span>protected</span><span> function query($request) { $context </span>= stream_context_create(array(<span>'</span><span>http</span><span>'</span> =><span> array( </span><span>'</span><span>method</span><span>'</span> => <span>"</span><span>POST</span><span>"</span><span>, </span><span>'</span><span>header</span><span>'</span> => <span>"</span><span>Content-Type: text/xml</span><span>"</span><span>, </span><span>'</span><span>content</span><span>'</span> =><span> $request ))); $xml </span>= file_get_contents($<span>this</span>->url, <span>false</span><span>, $context); </span><span>return</span><span> xmlrpc_decode($xml); } </span><span>public</span><span> function __call($method , $args) { $request </span>=<span> xmlrpc_encode_request($method , $args); </span><span>return</span> $<span>this</span>-><span>query($request); } } $rpc </span>= <span>new</span> rpcclient(<span>'</span><span>http://localhost/00/rpcs.php</span><span>'</span><span>); var_dump($rpc</span>-><span>hello()); var_dump($rpc</span>->sum(<span>4</span>,<span>5</span>,<span>6</span>));
The difference between WebService and json Api
WebService json API
Data encapsulation XML Json
Complexity High ceddie _ on data encapsulation †XML Documentation
The above has introduced WebService-php-2 (17), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.