These days work requires a. NET site to access PHP's wiki site without landing.
PHP is not familiar, feel very bitter force. The task is down and must be done. Ready to use SSO, too troublesome, to rewrite a lot of code, this is a third-party CMS, packaging is very bad, not good change. Finally my solution is to take my confident solution:
1). NET system users, add a role, wikiadmin, Authorization EPRG system outside the chain. A user with this role can see a link to the wiki on the EPRG system.
2) User & role name data is synchronized from wellmed to the wiki database. [The wiki needs to provide an interface for adding users to manually write Web service. NET invoke Web Service via HTTP web)
3) Click on the wiki link, jump to the. NET page Etools/wiki,controller code to invoke the Wiki service, add users to the wiki system, complete the Reuturn view, in the view Automatic POST request to the wiki login page, after login, as before, jump to the first page, the whole process users can not see.
It took a lot of time to configure the PHP service. Follow the on-line method, before doing this test, make sure that your PHP configuration file has the SOAP extension open, that is, Extension=php_soap.dll, and found none in the Php_soap.dll project. To download a usable one, ask a friend to say that to download the same as the current PHP version, otherwise it may not work. Liense is 3.1, but PHP officially does not have this version, suspected Liense does not represent the PHP version. Finally through the search engine know Phpinfo (); The method can print out the environment variable information of PHP, and know that my version is 5.4.25.
In php.net official download PHP, copy Php_soap.dll to \php\ext\ folder.
Modify \php\php.ini to add a line of code, Extension=php_soap.dll, to support SOAP extensions.
Write server.php server code, client side Test call. Success.
Try a. NET call. It is found that PHP itself calls itself without the WSDL file, and the. NET call must have a WSDL file. Find a way to generate a WSDL file.
Finally it took a long time, using Zend Studio, referring to the online WSDL format, and finally finished.
Discovery. NET adds a reference, and can also be invoked successfully.
Then perfect the concrete Usermanager method. The data is saved in the. php source file. Finally, it is implemented by the following methods.
<?PHPclassTest { Public function__construct () {} Public functionUpdateUser ($userName,$pwd,$fullName,$email,$groups) { $file= ' conf/users.auth.php '; $content=file_get_contents($file); $array=Explode("\ n",$content); $newUserInfo=$userName.‘:‘.MD5($pwd).‘:‘.$fullName.‘:‘.$email.‘:‘.$groups; $myfile=fopen("conf/users.auth.php", "w") or die("Unable to open file!"); $isUserExists=false; for($i= 0;$i<Count($array);$i++) { if(strlen($array[$i]) >5) { //foreach each user info $arrUserInfo=Explode(":",$array[$i]); //user exists, update user; $rs=strcasecmp($arrUserInfo[0],$userName); if($rs==0) { $isUserExists=true; $content=Str_replace($array[$i],$newUserInfo,$content); Break; } } } //Not exists, add user, append to last. if($isUserExists==false) { $content=$content." \ n ".$newUserInfo; } fwrite($myfile,$content); fclose($myfile); return"Success"; } Public functionGetList$type) { $result=Array( Array(' name ' = ' Zhangsan ', ' age ' =>18),Array(' name ' = ' Lisi ', ' age ' =>20) ); $result= Json_encode ($result); return $result; }}?>
View Code
You also need to add security certifications.
Reference: http://www.cnblogs.com/mbailing/p/3998821.html
Http://www.cnblogs.com/zzxbest/archive/2011/09/21/2184252.html
PHP note-php in Web Service.