¼ÙÉèÓÐ0¸öÍøÕ¾£¬·Ö²¼ÔÚ¸÷µØ£¬ËüÃÇµÄ¿â´æÒªÍ¬²½£¬¶øÊý¾Ý¿â²»Ö§³ÖÔ¶³ÌÁ¬½Ó¡£
¡¡¡¡ÎÒÃÇҪʵʱµØÈ¡µÃ·þÎñÆ÷µÄ¿â´æÊý£¬¿ÉÒÔͨ¹ýºÜ¶àÖÖ·½·¨£¬ÎÒËùÖªµÀµÄÓÐÒÔϼ¸ÖÖ£º
¡¡¡¡¡¡?CURL·½Ê½
¡¡¡¡¡¡?SOCKET·½Ê½
¡¡¡¡¡¡?PHPÖеÄSOAP·½Ê½
¡¡¡¡ÒÔÏÂ·Ö±ð¸ø³öʾÀýÀ´ÊµÏÖËü£º
¡¡¡¡CURL·½Ê½
¡¡¡¡client.php
£¼?php
$psecode = ¡¯NDE00¡¯;
$website = ¡¯www.abc.com¡¯;
$amt = ;
$pwd = 6;
$ch = curl_init();
$curl_url = "http://ics.server.com/index.php?web=" . $website .
"&pwd=" . $pwd . "&action=check&pseid=" . $psecode .
"&amt=" . $amt;
curl_setopt($ch, CURLOPT_URL, $curl_url);
curl_setopt($ch, CURLOPT_POST, );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, );//²»Ö±½ÓÊä³ö£¬·µ»Øµ½±äÁ¿
$curl_result = curl_exec($ch);
$result = explode(¡¯,¡¯, $curl_result);
curl_close($ch);
print_r($result);
?£¾
¡¡¡¡·þÎñÆ÷¶ËÖ»Ðè°´Ò»¶¨µÄ¸ñʽÊä³ö£¬È»ºó¿Í»§¶Ë°´´Ë¸ñʽ½ÓÊվͿÉÒÔÁËÈ磺
echo "OK," . $fpsecode . "," . $fbalance ;//ÒÔ¶ººÅ·Ö¸ô
¡¡¡¡SOCKET·½Ê½
¡¡¡¡Õâ¸öÒª½èÖúµÚÈý·½Àà¿âHttpClient,¿ÉÒÔµ½ÕâÀïÏÂÔØ£ºhttp://scripts.incutio.com/httpclient/
£¼?php
require_once ¡¯class/HttpClient.php¡¯;
$params = array(¡¯web¡¯ =£¾ ¡¯www.abc.com¡¯,
¡¯pwd¡¯ =£¾ ¡¯6¡¯,
¡¯action¡¯ =£¾ ¡¯check¡¯,
¡¯pseid¡¯ =£¾ ¡¯NDE00¡¯,
¡¯amt¡¯ =£¾ );
$pageContents = HttpClient::quickPost(¡¯http://ics.server.com/index.php¡¯, $params);
$result = explode(¡¯,¡¯, $pageContents);
print_r($result);
?£¾
¡¡¡¡PHPÖеÄSOAP·½Ê½
¡¡¡¡server.php
£¼?php
function getQuote($fpsecode) {
global $dbh;
$result = array();
try {
$query = "SELECT fprice, fcansale, fbalance, fbaltip FROM tblbalance where upper(trim(fpsecode)) = :psecode limit ";
$stmt = $dbh-£¾prepare($query);
$stmt-£¾execute(array(¡¯:psecode¡¯ =£¾ strtoupper(trim($fpsecode))));
$stmt-£¾bindColumn(¡¯fprice¡¯, $fprice);
$stmt-£¾bindColumn(¡¯fcansale¡¯, $fcansale);
$stmt-£¾bindColumn(¡¯fbalance¡¯, $fbalance);
$stmt-£¾bindColumn(¡¯fbaltip¡¯, $fbaltip);
while($row = $stmt-£¾fetch(PDO_FETCH_BOUND)) {
//
}
} catch (PDOException $e) {
echo $e-£¾getMessage();
}
return $fprice; //Äã¿ÉÒÔ·µ»ØÒ»¸öÊý×é
}
$dsn = ¡¯pgsql:host=9.68.*.* port= dbname=db user=6 password=6¡¯;
try {
$dbh = new PDO($dsn);
} catch (PDOException $e) {
die(¡¯Connection failed: ¡¯ . $e-£¾getMessage());
}
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("stockquote.wsdl"); //ÅäÖÃÎļþ
$server-£¾addFunction("getQuote");
$server-£¾handle();
?£¾
¡¡¡¡stockquote.wsdl
£¼?xml version =¡¯.0¡¯ encoding =¡¯UTF-8¡¯ ?£¾
£¼definitions name=¡¯StockQuote¡¯
targetNamespace=¡¯http://example.org/StockQuote¡¯
xmlns:tns=¡¯ http://example.org/StockQuote ¡¯
xmlns:soap=¡¯http://schemas.xmlsoap.org/wsdl/soap/¡¯
xmlns:xsd=¡¯http://www.w.org/00/XMLSchema¡¯
xmlns:soapenc=¡¯http://schemas.xmlsoap.org/soap/encoding/¡¯
xmlns:wsdl=¡¯http://schemas.xmlsoap.org/wsdl/¡¯
xmlns=¡¯http://schemas.xmlsoap.org/wsdl/¡¯£¾
£¼message name=¡¯getQuoteRequest¡¯£¾
£¼part name=¡¯symbol¡¯ type=¡¯xsd:string¡¯/£¾
£¼/message£¾
£¼message name=¡¯getQuoteResponse¡¯£¾
£¼part name=¡¯Result¡¯ type=¡¯xsd:float¡¯/£¾
£¼/message£¾
£¼portType name=¡¯StockQuotePortType¡¯£¾
£¼operation name=¡¯getQuote¡¯£¾
£¼input message=¡¯tns:getQuoteRequest¡¯/£¾
£¼output message=¡¯tns:getQuoteResponse¡¯/£¾
£¼/operation£¾
£¼/portType£¾
£¼binding name=¡¯StockQuoteBinding¡¯ type=¡¯tns:StockQuotePortType¡¯£¾
£¼soap:binding style=¡¯rpc¡¯
transport=¡¯http://schemas.xmlsoap.org/soap/http¡¯/£¾
£¼operation name=¡¯getQuote¡¯£¾
£¼soap:operation soapAction=¡¯urn:xmethods-delayed-quotes#getQuote¡¯/£¾
£¼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=¡¯StockQuoteService¡¯£¾
£¼port name=¡¯StockQuotePort¡¯ binding=¡¯StockQuoteBinding¡¯£¾
£¼soap:address location=¡¯http://9.68..9/php/server.php¡¯/£¾
£¼/port£¾
£¼/service£¾
£¼/definitions£¾
client.php
£¼?php
$client = new SoapClient("stockquote.wsdl");
$result = $client-£¾getQuote("nde00");
print_r($result);
?£¾

