下面我用它的客户端在php中编写了一个soap webservice的代码,它工作正常,实际上是php的新手,所以不知道如何从html页面将数据发布到我的服务器php服务,我知道使用javascript它是可能,但如何......任何代码或有用链接的帮助将不胜感激。
<?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.