PHP Web service(wsdl-mode) Question
Posted: Mon Jan 25, 2010 11:37 am
hello everyone!
I d like to create a php web service that insert a patient to the db, using SOAP and WSDL.
Can i create a php class to be consumed without taking any parameters from the client?
For example:
A client including a form like this:
and a handler class (service) like this:
server
Thank you!
I d like to create a php web service that insert a patient to the db, using SOAP and WSDL.
Can i create a php class to be consumed without taking any parameters from the client?
For example:
A client including a form like this:
Code: Select all
....
<p align="center" valign="top">
<form name="addP" action="index.php?type=addPatientToDB" method="POST" onSubmit="return check(this);">
<table align="center" width="500px" border="1">
<tr>
<td colspan="2" align="center"><h2>???????? ??????</h2></td>
</tr>
<tr>
<td>FName :</td>
<td><input name="firstname" type="text" size="50"></td>
</tr>
<tr>
<td>LName:</td>
<td><input name="lastname" type="text" size="50"></td>
</tr>
<tr>
<td>Identity :</td>
<td><input name="identity" type="text" size="50"></td>
</tr>
<tr>
<td align="center"><input type="reset" name="reset" value="Clear"></td>
<td align="center"><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
</p>
....
....
$client=new SoapClient($wsdl);
$client->insertPatient();
Code: Select all
<?php
Class MyClass {
function insertPatient{
if($_POST["firstname"] != "" && $_POST["lastname"] != "" && $_POST["identity"] != "" ){
$db = "mydb";
$sql = "INSERT INTO patients (userid, firstname, lastname, identity) VALUES (" . $_SESSION["userid"] . ", '" . $_POST["firstname"] . "', '" . $_POST["lastname"] . "', '" . $_POST["identity"] . "') ";
include($folder["query"]);
}
else{
die("Please insert all info");
}
echo("<script type=\"text/javascript\" language=\"Javascript\">
<!--
window.open('index.php?type=showPatients&identity=" . $_POST["identity"] . "', '_self');
-->
</script>");
}
?>
Code: Select all
require_once "MyClass.php";
$wsdl=......
$srv=new SoapServer($wsdl);
$srv->setClass("MyClass");
$srv->handle();