Reprinted please indicate the source: http://blog.csdn.net/cwt0408/article/details/6952936
(Thank you for your cooperation !)
Call the array content:
1. Modify service. php
<? Phpclass phonebookinfo {public $ name, $ number, $ relationship, $ email; public function _ construct ($ pname, $ pnumber, $ prelationship, $ pemail) {$ this-> name = $ pname; $ this-> Number = $ pnumber; $ this-> relationship = $ prelationship; $ this-> email = $ pemail ;}} /* You can call the database here. The following is the test data */function getphonebook ($ inname) {$ pinfo = array (); $ pinfo [] = new phonebookinfo ('zhangsan ', '200', 'friend', '192 @ 163.com '); $ pinfo [] = new phonebooki Nfo ('lisi', '000000', 'friend', '2017 @ 163.com '); $ pinfo [] = new phonebookinfo ('hangzhou', '2017030 ', 'friend', '1970 @ 163.com '); return $ pinfo;} $ Server = new soapserver ("Myphone. WSDL "); $ server-> addfunction (" getphonebook "); $ server-> handle ();?>
2. Client. php
<?phpheader('Content-Type:text/html;charset=utf-8');$client = new SoapClient("http://www.mysoapservice.cn/service.php?WSDL" , array('trace'=>true));var_dump($client->__getTypes());try { $response = $client->GetPhoneBook('zhang'); var_dump($response);}catch (SoapFault $sf){ var_dump($sf); print ($client->__getLastRequest()); print ($client->__getLastResponse());}?>
3. Modify Myphone. WSDL
<?xml version ='1.0' encoding ='UTF-8' ?> <definitions name='phonebook' targetNamespace='http://www.mysoapservice.cn/' xmlns:tns='http://www.mysoapservice.cn/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/'> <types> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.mysoapservice.cn/" xmlns:Q1="soapenc"> <xsd:complexType name="PhoneBookInfoArray"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <xsd:attribute ref="sopenc:arrayType" wsdl:arrayType="tns:PhoneBookInfo[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> <xsd:complexType name="PhoneBookInfo"> <xsd:all> <xsd:element name="name" type="xsd:string"></xsd:element> <xsd:element name="number" type="xsd:string"></xsd:element> <xsd:element name="relationship" type="xsd:string"></xsd:element> <xsd:element name="email" type="xsd:string"></xsd:element> </xsd:all> </xsd:complexType> </xsd:schema> </types> <message name='GetPhoneBookRequest'> <part name="inname" type="xsd:string"/></message> <message name='GetPhoneBookResponse'> <part name="phonebookInfo" type="xsd:PhoneBookInfoArray"/></message><portType name='PhoneBookToEveryOneProt'> <operation name='GetPhoneBook'> <input message='tns:GetPhoneBookRequest'/> <output message='tns:GetPhoneBookResponse'/> </operation></portType><binding name='PhoneBookSOAP' type='tns:PhoneBookToEveryOneProt'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='GetPhoneBook'> <soap:operation soapAction='http://www.cwtservice.cn/newOperation/'/> <input> <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </input> <output> <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </output> </operation> </binding><service name='PhoneBookService'> <port name='PhoneBookSOAP' binding='tns:PhoneBookSOAP'> <soap:address location='http://www.mysoapservice.cn/service.php'/> </port> </service> </definitions>
Comparison and modification:
Test results:
Note the following:
If an I/O error occurs:
1. Open extension = php_curl.dll in PHP. ini.
2. Copy: libeay32.dll and ssleay32.dll to system32
Both DLL files are downloaded online! I won't upload it!