 |
การเปลี่ยน code PHP+Mysql to PHP+ Oracle for soap server & client |
|
 |
|
|
 |
 |
|
WebService1.php
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com</title>
</head>
<body>
<form name="frmMain" method="post" action="">
<h2>Search Customer</h2>
Search by Country Code
<input type="text" name="txtCountry" value="<?=$_POST["txtCountry"];?>">
<input type="submit" name="Submit" value="Submit">
</form>
<?
if($_POST["txtCountry"] != "")
{
include("lib/nusoap.php");
$client = new nusoap_client("http://localhost/nusoap/WebServiceServer.php?wsdl",true);
$params = array(
'strCountry' => $_POST["txtCountry"]
);
$data = $client->call('resultCustomer', $params);
//echo '<pre>';
//var_dump($data);
//echo '</pre><hr />';
if(count($data) == 0)
{
echo "Not found data!";
}
else
{
?>
<table width="500" border="1">
<tr>
<td>CustomerID</td>
<td>Name</td>
<td>Email</td>
<td>CountryCode</td>
<td>Budget</td>
<td>Used</td>
</tr>
<?
foreach ($data as $result) {
?>
<tr>
<td><?=$result["CustomerID"];?></td>
<td><?=$result["Name"];?></td>
<td><?=$result["Email"];?></td>
<td><?=$result["CountryCode"];?></td>
<td><?=$result["Budget"];?></td>
<td><?=$result["Used"];?></td>
</tr>
<?
}
}
}
?>
</body>
</html>
WebServiceServer.php
Code (PHP)
<?
require_once("lib/nusoap.php");
//Create a new soap server
$server = new soap_server();
//Define our namespace
$namespace = "http://localhost/nusoap/WebServiceServer.php";
$server->wsdl->schemaTargetNamespace = $namespace;
//Configure our WSDL
$server->configureWSDL("getCustomer");
//Add ComplexType
$server->wsdl->addComplexType(
'DataList',
'complexType',
'struct',
'all',
'',
array(
'CustomerID' => array('name' => 'CustomerID', 'type' => 'xsd:string'),
'Name' => array('name' => 'Name', 'type' => 'xsd:string'),
'Email' => array('name' => 'Email', 'type' => 'xsd:string'),
'CountryCode' => array('name' => 'CountryCode', 'type' => 'xsd:string'),
'Budget' => array('name' => 'Budget', 'type' => 'xsd:float'),
'Used' => array('name' => 'Used', '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(
'strCountry' => "xsd:string"
);
// Register service and method
$server->register('resultCustomer', // method name
$varname, // input parameters
array('return' => 'tns:DataListResult'));
function resultCustomer($strCountry)
{
$objConnect = mysql_connect("localhost","root","kasx123") or die(mysql_error());
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer WHERE 1 AND CountryCode like '%".$strCountry."%' ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$intNumField = mysql_num_fields($objQuery);
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
mysql_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();
?>
Tag : PHP, MySQL, CakePHP, Web Service, Yii PHP Framework
|
|
 |
 |
 |
 |
Date :
2013-11-23 11:28:59 |
By :
xaybanhthone |
View :
1116 |
Reply :
14 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใคร ช่วย ตอบ ...
|
 |
 |
 |
 |
Date :
2013-11-23 17:24:16 |
By :
xaybanhthone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จะถามว่าอะไรครับ
                                     
                                     
                                     
                                     
                                     
                                     
                                     
                                     
                                     
                                     
                                     
|
ประวัติการแก้ไข 2013-11-23 18:07:06 2013-11-23 18:16:23 2013-11-23 18:17:10 2013-11-23 18:18:17 2013-11-23 18:20:11 2013-11-23 18:21:23 2013-11-23 18:23:01
 |
 |
 |
 |
Date :
2013-11-23 18:06:26 |
By :
itpcc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในตัวอย่าง WebServiceServer.php
PHP+Mysql
ผมต้องการที่จะเปลี่ยน
code PHP+ Oracle
ช่วยฉันด้วย
Code (PHP)
function resultCustomer($strCountry)
{
$objConnect = mysql_connect("localhost","root","kasx123") or die(mysql_error());
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer WHERE 1 AND CountryCode like '%".$strCountry."%' ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$intNumField = mysql_num_fields($objQuery);
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
mysql_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();
|
ประวัติการแก้ไข 2013-11-23 20:33:41
 |
 |
 |
 |
Date :
2013-11-23 20:08:20 |
By :
xaybanhthone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2013-11-23 22:35:40 |
By :
telesyn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
PHP Oracle
|
 |
 |
 |
 |
Date :
2013-11-23 23:31:32 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยแปลงให้ฉันด้วย
ผมมือใหม่นะคบ
|
 |
 |
 |
 |
Date :
2013-11-24 07:24:20 |
By :
xaybanhthone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลงมือทำเอง่กอนไหม เป็นลูกนกอ้าปาก รออย่างเดียวไม่ไหวม้าง 
|
 |
 |
 |
 |
Date :
2013-11-24 08:05:38 |
By :
telesyn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำแล้วแต่ไม่ work
|
 |
 |
 |
 |
Date :
2013-11-24 08:14:26 |
By :
xaybanhthone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวอย่างก็มีครับ 
|
 |
 |
 |
 |
Date :
2013-11-24 10:46:31 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
nusoap server & client
|
 |
 |
 |
 |
Date :
2013-11-24 12:16:12 |
By :
xaybanhthone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
No. 12 : ตัวอย่างก็มีครับ 
No. 13 : nusoap server & client
No. 14 : ??
|
 |
 |
 |
 |
Date :
2013-11-25 08:55:53 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|