Below i have written code of a soap webservice in php with its client,It is working fine, actually m new to php so don’t know how to post data to my server php service from html page, i know by using javascript it is possible but how…..any help by code or helpful link will be appreciated.
<?php
require_once "lib/nusoap.php";
function getProd($username,$password) {
$user = "root";
$pswd = "root";
$db = "LOGIN";
$conn = mysql_connect('localhost', $user, $pswd);
mysql_select_db($db, $conn);
//run the query to search for the username and password the match
$query = "SELECT * FROM PEOPLE WHERE USERNAME = '$username' AND PASSWORD = '$password'";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
//this is where the actual verification happens
if(mysql_num_rows($result) > 0)
$valid="LoginSucessful";
else
$valid="LoginFailed";
return $valid;
}
$server = new soap_server();
$server->configureWSDL("productlist", "urn:productlist");
$server->register("getProd",
array("username" => "xsd:string","password" => "xsd:string"),
array("return" => "xsd:string"),
"urn:productlist",
"urn:productlist#getProd",
"rpc",
"encoded",
"Get a listing of products by category");
if ( !isset( $HTTP_RAW_POST_DATA ) ) $HTTP_RAW_POST_DATA =file_get_contents( 'php://input' );
$server->service($HTTP_RAW_POST_DATA);
#client of service#
<?php
require_once "lib/nusoap.php";
$client = new nusoap_client("http://localhost/expa/productlis.php");
$result = $client->call("getProd",array("category" => "admin","item" => "admin"));
Overall just need to pass parameter to the php function.
There are few ways to get data from the user:
Pass data via url parameters:
A straight up form:
Ajax
If you need to submit the data without reloading via javascript the page you would use AJAX.
This is an example using jQuery that catches the form submit event and sends the form without reloading the page.