PHP enterprise-level application WebService

Source: Internet
Author: User
For enterprise-level applications, PHP 5 implements webservice (the following programs can be normally called by JAVA, NET, and C)

For enterprise-level applications, PHP 5 implements webservice (the following programs can be normally called by JAVA, NET, and C)

There are very few webservices written using PHP in China, and there is not much information on the internet. during the company's project development process, there have been many such things, write it for your reference (thanks to the WSDL and program files provided by Lao Nong)

Client

Header ("Content-Type: text/html; charset = utf-8 ");
/*
* Specify the WebService path and initialize a WebService client.
*/
$ Ws = "http: // soap/soapCspMessage. php? Wsdl ";
$ Client = new SoapClient ($ ws, array ('Trace '=> 1, 'uri' => 'http: // www.zxsv.com/SoapDiscovery /'));
/*
* Obtain all methods provided by the service referenced by the SoapClient object
*/
Echo ("open functions provided by the SOAP server :");
Echo ('

');
var_dump ( $client->__getFunctions () );
echo ('
');
Echo ("Type provided by the SOAP server :");
Echo ('
');
var_dump ( $client->__getTypes () );
echo ('
');
Echo ("result of GetGUIDNode execution :");
// $ Users = $ client-> GetUsers ();
// Var_dump ($ HelloWorld );
$ Parameters = array ('uname' => 'zxsv', "upassword" => '123 ');
$ Out = $ client-> HelloWorld ($ parameters );
$ Datadb = $ out-> HelloWorldResponse;
Var_dump ($ out );
?>

Server

Class Member
{
Public $ UserId;
Public $ Name;
Public function _ construct ($ parmas ){
$ This-> UserId = $ parmas [0];
$ This-> Name = $ parmas [1];
}
}
$ ServidorSoap = new SoapServer ('testphp. xml ', array ('uri' => 'http: // www.testphp.com/', 'encoding' => 'utf-8', 'soap _ version' => SOAP_1_2 ));
$ ServidorSoap-> setClass (Testphp );
$ ServidorSoap-> handle ();
Class Testphp {
Public function HelloWorld ($ uid ){
Return array ('helloworldresult' => "mystring". $ uid-> {'uname'}. 'and'. $ uid-> {'upassword '});
}
Public function GetMember ($ uid ){
$ S = array ();
For ($ I = 0; $ I <$ uid-> {'uid'}; $ I ++ ){
$ S [] = & new Member (array ($ I, $ uid-> {'uname'}. 'test '. $ I ));
}
Return array ('getmemberresult' => $ s );
}
}
?>

I should understand it all here.
Below is the WSDL file
























































































































 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.