I need some help understanding concepts as Im not sure how to achieve this.
I’ve got a database up on the web and it works pretty well with php which its written in. I now need to create the ability for an asp.net page to query my php database and return the results in a format which is fairly easy to manipulate at the other end, json would be good.
The problem I have is the security of the php database. If I have the credentials embedded in the file (like below), I run the db being insecure to queries. So doing some research, it looks like I need to look into webservices as I can pass the username and password from the ASPX page securely using SOAP headers. Can someone confirm that is true?
$databaseName = 'MySample';
$userName = 'MyUserName';
$passWord = 'MyPassword';
$db = & new Database();
$db->setProperty('database', $databaseName);
$db->setProperty('username', $userName);
$db->setProperty('password', $passWord);
//this is the find
$findCMD = $db->newFindCommand('Web');
$findCMD->AddFindCriterion('Field1',$_POST['Param1']);
$findCMD->AddFindCriterion('Field2',$_POST['Param2']);
//finally execute and return $Results back to the ASPX app
$Results = $findCMD->execute();
Can SOAP return results as JSON, or is it specifically XML? I’ve also been trying to find some turorials in setting up a webservice for PHP 5.3, most of them point towards nusoap – ive tried to follow a basic tutorial which failed. According to reports this library isnt compatible with 5.3 and there is a port, but is that the best library to try and use or shall I try and use the built in soap library, which there are not many tutorials about?
My main objective is to provide secure access to my PHP Database from an ASPX page, PS everything is being done in HTTPS.
Any advice would be great, continuing on my search in the meantime to sift through RESTful services, see if they are what I should be using.
Thanks as always
SOAP is primarily XML. You could send a json message inside a SOAP response, but its probably not going to be very effcient. With rest you can send back any format you want and/or use context switching to send a response in your preferred format.