NuSoap½éÉÜ (phpµ÷ÓÃwebservice)(תÔØ)
http://hi.baidu.com/honfei/blog/item/5e992bfb2704542b4f4aea1a.html
NuSoap½éÉÜ (phpµ÷ÓÃwebservice)
2009Äê07ÔÂ04ÈÕ ÐÇÆÚÁù 09:41
NuSOAP ÊÇ PHP »·¾³Ï嵀 WEB ·þÎñ±à³Ì¹¤¾ß£¬ÓÃÓÚ´´½¨»òµ÷Óà WEB ·þÎñ¡£ËüÊÇÒ»¸ö¿ªÔ´Èí¼þ£¬µ±Ç°°æ±¾ÊÇ 0.7.2 £¬Ö§³Ö SOAP1.1 ¡¢ WSDL1.1 £¬¿ÉÒÔÓëÆäËûÖ§³Ö SOAP1.1 ºÍ WSDL1.1 µÄϵͳ»¥²Ù×÷¡£ NuSOAP ÍêÈ«ÓÉPHPÓïÑÔ±àд£¬ÓÉһϵÁÐ PHP Àà×é³É£¬²»ÐèÒªÀ©Õ¹¿âµÄÖ§³Ö£¬ÕâÖÖÌØÐÔʹµÃ NuSOAP ¿ÉÒÔÓÃÓÚËùÓÐµÄ PHP »·¾³£¬²»ÊÜ·þÎñÆ÷°²È«ÉèÖõÄÓ°Ïì¡£
1. NuSOAP µÄ»ñÈ¡ºÍ°²×°
NuSOAP ÏîÄ¿½¨Á¢ÔÚ SourceForge ÉÏ£¬ÍøÂçµØÖ·ÊÇ£º http://sourceforge.net/projects/nusoap/ »ò http://dietrich.ganx4.com/nusoap£¬ÕâÀ¿ÉÒÔÏÂÔص½ NuSOAP µÄ×îеİ汾¡£
NuSOAP µÄ°²×°±È½Ï¼òµ¥£¬°ÑÏÂÔØµÄ NuSOAP µÄÎļþ¿½±´µ½·þÎñÆ÷ÉÏ£¬¿ÉÒÔ·ÅÔÚ¶ÀÁ¢µÄĿ¼ÀҲ¿ÉÒÔÓë³ÌÐò´úÂë·ÅÔÚÏàͬµÄĿ¼ÀֻҪÄãµÄ PHP ´úÂëÄܹ»·ÃÎʵ½ÕâЩÎļþ¾Í¿ÉÒÔÁË¡£
±¾ÎĵIJâÊÔ»·¾³»ùÓÚ PHP4.3.2 ºÍ NuSOAP 0.7.2 °æ±¾£¬ NuSOAP °²×°ÔÚ WEB Ŀ¼“ /nusoap ”ÀÓÐÁ½¸ö×ÓĿ¼£¬ lib ºÍ samples ¡£ÆäÖУ¬ lib Ŀ¼Ï´æ·Å NuSOAP µÄËùÓÐÔ´´úÂëÎļþ£¬ samples Ŀ¼ÏÂÊÇNuSOAP¿ª·¢Ð¡×éÌṩһЩµÄÀý×Ó¡£²âÊÔÎļþ´æ·ÅÔÚ WEB Ŀ¼“ /nusoap ”Àï¡£
2. NuSOAP µÄʹÓÃ
NuSOAP ÓÉÒ» PHP µÄÀà×é³É£¬ÆäÖÐ×î³£Óõ½µÄÊÇÀàsoap_serverºÍÀàsoalclient¡£Ààsoap_server ÓÃÓÚ´´½¨ WEB ·þÎñ£¬ÀàsoapclientÔÚ·ÃÎÊWEB·þÎñʱ»áÓõ½¡£
2.1 Ò»¸ö¼òµ¥µÄÀý×Ó£º Hello World
Õâ¸öÀý×Ó½«ÀûÓà NuSOAP ´´½¨Ò»¸ö¼òµ¥µÄ WEB ·þÎñ£¬²¢ÀûÓà NuSOAP ´´½¨Ò»¸ö¿Í»§¶Ë³ÌÐò£¬µ÷ÓÃÕâ¸ö·þÎñ¡£Õâ¸ö·þÎñΨһµÄ¹¦ÄܾÍÊÇÏò¿Í»§¶Ë·µ»ØÒ»¸ö×Ö·û´®“ Hello World ”¡£Ê×ÏÈ£¬´´½¨ WEB ·þÎñ³ÌÐò´úÂëÎļþ“ /nusoap/nusoap_server1.php ”£º
//°Ñ NuSOAP µÄÔ´Îļþ°üº¬µ½µ±Ç°µÄ´úÂëÎļþÀï
<?php
require_once("lib/nusoap.php");
//¶¨Òå·þÎñ³ÌÐò
function hello() {
return 'Hello World!';
}
//³õʼ»¯·þÎñ¶ÔÏó , Õâ¸ö¶ÔÏóÊÇÀà soap_server µÄÒ»¸öʵÀý
$soap = new soap_server;
//µ÷Ó÷þÎñ¶ÔÏóµÄ register ·½·¨×¢²áÐèÒª±»¿Í»§¶Ë·ÃÎʵijÌÐò¡£
//Ö»ÓÐ×¢²á¹ýµÄ³ÌÐò£¬²ÅÄܱ»Ô¶³Ì¿Í»§¶Ë·ÃÎʵ½¡£
$soap->register('hello');
//×îºóÒ»²½£¬°Ñ¿Í»§¶Ëͨ¹ý post ·½Ê½Ìá½»µÄÊý¾Ý£¬´«µÝ¸ø·þÎñ¶ÔÏóµÄ service ·½·¨¡£
//service ·½
Ïà¹ØÎĵµ£º
ÎÒ´òËãÔÚÃüÁîÐÐÖÐÕâÑùµ÷ÓÃphp£º cat filename|php a.php£¬ÈÃa.php¶ÁÈ¡filenameÀïÃæµÄÿÐмǼ½øÐд¦Àí£¬·½·¨ÈçÏ£º
<?php
$fp = fopen("/dev/stdin", "r");
while($input = fgets($fp, 10000))
{
echo urldecode($input);
}
?>
......
ÕâƪÎÄÕµijö·¢µãÊÇÎÒ¶Ô²å¼þ»úÖÆ
µÄÀí½â£¬¼°ÆäÔÚPHPÖеÄʵÏÖ¡£´Ë·½°¸½öÊDzå¼þ»úÖÆÔÚPHPÖеÄʵÏÖ·½°¸Ö®Ò»£¬Ð´ÏÂÀ´ºÍ´ó¼Ò·ÖÏí£¬»¶Ó´ó¼ÒÒ»ÆðÌÖÂÛ¡£
²å¼þ
£¬Ò༴Plug-in£¬ÊÇÖ¸Ò»ÀàÌض¨µÄ¹¦ÄÜÄ£¿é£¨Í¨³£ÓɵÚÈý·½¿ª·¢ÕßʵÏÖ£©£¬ËüµÄÌصãÊÇ£ºµ±ÄãÐèÒªËüµÄʱºò
¼¤»îËü£¬²»ÐèÒªËüµÄʱºò½ûÓÃ/ɾ³ýËü£»ÇÒÎÞÂÛÊǼ¤»î»¹ÊǽûÓö¼²»Ó° ......
ƽʱÓà htmlspecialchars() À´¹ýÂËhtml, µ«ÊÇ°ÑhtmlµÄ×Ö·ûתÒåÁË,×îºóÏÔʾ³öÀ´µÄ¾ÍÊÇhtmlÔ´´úÂë, ÀûÓÃstrip_tags()¾Í¿ÉÒÔ°Ñhtml±êÇ©È¥³ýµô.
[php]
$str = 'harryxu
‘;
echo(htmlspecialchars($str) . ‘
‘);
echo(strip_tags($str));
// output:
// harryxu
// harryxu
?>
......
ÓÃPHPдһ¸ö×Ô¼ºµÄÄ£°åÒýÇæ
2009-07-11 09:51
SmartyÒ»Ö±±»ÈËÊÓΪÊǶàÓàµÄ¶«Î÷£¬ÎÒ¾õµÃÈÏΪSmarty¶àÓàµÄÈ˲ÅÊǶàÓàµÄ....²»ËµÕâЩÁË¡£½ñÌìÎҾͽ̴ó¼Òд¸öÄ£°åÒýÇ棬Èôó¼Ò¶¼¿ÉÒÔдһ¸öÊôÓÚ×Ô¼ºµÄÄ£°åÒýÇ棬¶øÇÒ¿´ÍêÕâƪÎÄÕÂÖ®ºó£¬Äã¶ÔSmartyµÄÈÏʶ»á¸ü½øÒ»²½µÄ¡£ÎÒµÄÄ£°åÒýÇæÃû½ÐStupid£¨"ɵ¹Ï"µÄÒâ˼£©£¬ÎÒ²»Ï ......
ÔÚPHPÖÐʹÓùýSESSIONµÄÅóÓÑ¿ÉÄÜ»áÅöµ½Õâôһ¸öÎÊÌ⣬SESSION±äÁ¿²»ÄÜ¿çÒ³´«µÝ¡£ÕâÁîÎÒ¿àÄÕÁ˺ÃЩÈÕ×Ó£¬×îÖÕͨ¹ý²é×ÊÁÏ˼¿¼²¢½â¾öÁËÕâ¸öÎÊÌâ¡£ÎÒÈÏΪ£¬³öÏÖÕâ¸öÎÊÌâµÄÔÒòÓÐÒÔϼ¸µã£º
1¡¢¿Í»§¶Ë½ûÓÃÁËcookie
2¡¢ä¯ÀÀÆ÷³öÏÖÎÊÌ⣬ÔÝʱÎÞ·¨´æÈ¡cookie
3¡¢php.iniÖеÄsession.use_trans_sid = 0»òÕß±àÒëʱûÓдò¿ª--enable ......