|
|
|
PHP Web Service Using Nusoap บันทึกติดแต่ไม่ส่งค่ากลับมาครับ |
|
|
|
|
|
|
|
คือว่าผมส่ง array ไปเพื่อ insert sql แล้ว return string กลับมาเพื่อ echo สามารถ insert sql ได้แต่ return string ไม่กลับมาครับ มัน NULL รบกวนพี่ๆหน่อยครับแก้ไขยังไง
หน้า Client
Code (PHP)
<?php
require 'lib/nusoap.php';
$client = new nusoap_client("http://localhost/test/profile_server.php?wsdl");
$params = array(
'com_Name_en' => "Nokia",
'com_Name_th' => "โนเกีย",
'phone' => "091-xxx-xxxx",
'address_en' => "12/1 Soi.Thakram",
'address_th' => "12/1 ซอย ท่าข้าม",
'insert_time' => date("Y-m-d H:i:s")
);
$response=$client->call('company',$params);
var_dump($response);
?>
หน้า Server
Code (PHP)
<?php
require_once("lib/nusoap.php");
$server = new nusoap_server();
$varname = array(
'com_Name_en' => "xsd:string",
'com_Name_th' => "xsd:string",
'phone' => "xsd:string",
'address_en' => "xsd:string",
'address_th' => "xsd:string",
'insert_time' =>"xsd:string"
);
$server->register('company',$varname, array('return' => 'xsd:string'));
function company($com_Name_en,$com_Name_th,$phone,$address_en,$address_th,$insert_time)
{
include('config.php');
$objConnect = mysql_connect($conf['url'],$conf['user'],$conf['pass']);
$objDB = mysql_select_db($conf['db_name']);
/*** Insert ***/
$strSQL = " INSERT INTO insert_company (com_Name_en,com_Name_th,phone,address_en,address_th,insert_time)
VALUES ('".$com_Name_en."','".$com_Name_th."','".$phone."','".$address_en."','".$address_th."','".$insert_time."')";
mysql_query("SET NAMES 'utf8'");
$objQuery = mysql_query($strSQL);
if($objQuery)
{
$arr = "Successful";
}
else
{
$arr = "Failed";
}
return $arr;
mysql_close($objConnect);
}
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($POST_DATA);
exit();
?>
Tag : PHP
|
|
|
|
|
|
Date :
2014-06-26 11:48:14 |
By :
babluebuu |
View :
753 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|