|
|
|
PHP Web Service MYSQL อยากได้วิธีการ insert data ด้วย nusoap ครับ รบกวนหน่อย |
|
|
|
|
|
|
|
Code (ฝั่ง Web Services)
<?
ob_start();
require_once("lib/nusoap.php");
//Create a new soap server
$server = new soap_server();
//Define our namespace
$namespace = "https://www.thaicreate.com/android/insertMemberData.php";
$server->wsdl->schemaTargetNamespace = $namespace;
//Configure our WSDL
$server->configureWSDL("insertMember");
// Register our method and argument parameters
$varname = array(
'strUsername' => "xsd:string",
'strPassword' => "xsd:string",
'strName' => "xsd:string",
'strEmail' => "xsd:string",
'strTel' => "xsd:string"
);
$server->register('insertMember',$varname, array('return' => 'xsd:string'));
function insertMember($strUsername,$strPassword,$strName,$strEmail,$strTel)
{
$objConnect = mysql_connect("localhost","root","root");
$objDB = mysql_select_db("mydatabase");
/*** Insert ***/
$strSQL = "INSERT INTO member (Username,Password,Name,Email,Tel)
VALUES (
'".$strUsername."',
'".$strPassword."',
'".$strName."',
'".$strEmail."',
'".$strTel."'
)
";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
$arr['StatusID'] = "0";
$arr['Error'] = "Cannot save data!";
}
else
{
$arr['StatusID'] = "1";
$arr['Error'] = "";
}
/**
$arr['StatusID'] // (0=Failed , 1=Complete)
$arr['Error'] // Error Message
*/
mysql_close($objConnect);
header('Content-type: application/json');
return json_encode($arr);
}
// 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();
?>
ส่วน Client ดูตามบทความนี้ครับ
PHP Create - Call Web Service สร้างและเรียกเว็บเซอร์วิส ด้วย PHP (NuSoap and Soap)
|
|
|
|
|
Date :
2014-06-06 10:11:33 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ ขอบพระคุณครับ ^_^
|
|
|
|
|
Date :
2014-06-06 10:47:06 |
By :
babluebuu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จัดไปครับ
|
|
|
|
|
Date :
2014-06-06 10:53:46 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|