Provides various official and user-released code examples. For more information, see thinkphp webservice.
Class Api {
Private $ key = null;
Public function _ construct (){
}
// Set the key
Public function setkey ($ key ){
$ This-> key = $ key;
Return "";
}
// Verify the key
Private function check_key (){
If ($ this-> key = 'xxx '){
Return true;
}
Return false;
}
Public function getInfo ($ lastupdt ){
Return "1231 ";
}
}
Class WbsAction extends Action {
Protected function _ initialize (){
$ This-> url = "http: // localhost/xx /";
Import ("SoapDiscovery ");
}
Public function index (){
If (IS_POST ){
$ ServidorSoap = new SoapServer ($ this-> url ."? Wsdl ");
$ ServidorSoap-> setClass ('api ');
$ ServidorSoap-> handle ();
} Else {
$ Disco = new SoapDiscovery ('api ', 'myapi ');
Header ("Content-type: text/xml ");
If (isset ($ _ SERVER ['query _ string']) & strcasecmp ($ _ SERVER ['query _ string'], 'wsdl ') = 0 ){
Echo $ disco-> getWSDL ();
}
Else {
Echo $ disco-> getDiscovery ();
}
}
}
Public function test (){
$ Time = I ("t ");
Ini_set ('soap. wsdl_cache_enabled ', "0"); // note that this option is cached in soap.
$ Client = new SoapClient ($ this-> url ."? Wsdl ");
$ Client-> setkey ('xxxx ');
// $ Client = new Api ();
Try {
// $ Result = $ client-> select ('ieliwb ');
$ Result = $ client-> getInfo ("$ time ");
Var_dump ($ result );
}
Catch (SoapFault $ f ){
Echo "Error Message: {$ f-> getMessage ()}";
}
}
}
SoapDiscovery.class.zip (2.19 KB download: 423 times)
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB