|
|
|
เขียน เว็บเซอร์วิสติดต่อกับ MS Access พอไม่รันที่ client มันแจ้งตามข้างล่างอ่ะ ค่ะต้องทำอย่างไรช่วยชี้้แนะด้วยค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
require_once("nusoap/lib/nusoap.php");
//Create a new soap server
$server = new soap_server();
//Define our namespace
$namespace = "http://127.0.0.1/webservice/ServiceServerMSAccess.php";
$server->wsdl->schemaTargetNamespace = $namespace;
//Configure our WSDL
$server->configureWSDL("getStudents");
//Add ComplexType
$server->wsdl->addComplexType(
'DataList',
'complexType',
'struct',
'all',
'',
array(
'std_id' => array('name' => 'std_id', 'type' => 'xsd:string'),
't_title' => array('name' => 't_title', 'type' => 'xsd:string'),
't_fname' => array('name' => 't_fname', 'type' => 'xsd:string'),
't_lname' => array('name' => 't_lname', 'type' => 'xsd:string'),
'id_no' => array('name' => 'id_no', 'type' => 'xsd:float'),
'sex' => array('name' => 'sex', 'type' => 'xsd:float')
)
);
//Add ComplexType
$server->wsdl->addComplexType(
'DataListResult',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:DataList[]')
),
'tns:DataList'
);
//Register our method and argument parameters
$varname = array(
'strCID' => "xsd:string"
);
// Register service and method
$server->register('resultStudents', // method name
$varname, // input parameters
array('return' => 'tns:DataListResult'));
function resultStudents($strCID)
{
$objConnect = odbc_connect("std","","") or die("Error Connect to Database");
// Search By Name or Email
$strSQL = "SELECT * FROM students WHERE 1 AND id_no = '".$strCID."' ";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
$intNumField = odbc_exec($objConnect, $strSQL);
$resultArray = array();
while($objResult = odbc_fetch_array($objExec))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
odbc_close($objConnect);
return $resultArray;
}
// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>
ผลรัน
Warning: Invalid argument supplied for foreach() in C:\AppServ\www\webservice\ClientMSAccess.php on line 45
Tag : PHP, Ms Access, WebService, Windows, Web Service
|
|
|
|
|
|
Date :
2013-09-27 23:00:52 |
By :
ping |
View :
613 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เข้าไป ดู ClientMSAccess.php ตรง บันทัดที่ 45 มันบอกว่า ไม่มีข้อมูลที่จะ foreach
|
|
|
|
|
Date :
2013-09-28 01:12:26 |
By :
yamcrocodile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
function resultStudents($strCID)
{
$objConnect = odbc_connect("std","","") or die("Error Connect to Database");
// Search By Name or Email
$strSQL = "SELECT * FROM students WHERE 1 AND id_no = '".$strCID."' ";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
$intNumField = odbc_exec($objConnect, $strSQL);
$resultArray = array();
while($objResult = odbc_fetch_array($objExec))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
odbc_close($objConnect);
return $resultArray;
}
ลองทำให้ตัวนีมันรันให้ได้ก่อนครับ
|
|
|
|
|
Date :
2013-09-28 06:01:55 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยแก้ให้หน่อยได้ไหมค่ะท่านผู้รู้
|
|
|
|
|
Date :
2013-09-28 10:44:29 |
By :
ping |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|