I have the php webservice code below, what I am suppose to do, so that I can call this web service in java.
I need to generate the wsdl first? Then generate the java web service stubs with the wsdl? How can I call this in java. And what tool I need to use. Thank you.
<?php include_once("../../lib/config.php"); ?>
<?php
if(!extension_loaded("soap")){
dl("php_soap.dll");
}
ini_set("soap.wsdl_cache_enabled","0");
$server = new SoapServer("membersearch.wsdl");
function doMyMemberSearch($membernumber){
$sqlMemberInfo = mysql_query("SELECT * FROM Member_Info WHERE Member_Number = '".$membernumber."'");
$rowMemberInfo = mysql_fetch_array($sqlMemberInfo);
$arr[] = array(
"anniversary" => $rowMemberInfo['Anniversary'],
"club" => $rowMemberInfo['Club'],
"level"=> $rowMemberInfo['Level'],
"delivery"=> $rowMemberInfo['Delivery'],
"firstname"=> $rowMemberInfo['First_Name'],
"lastname"=> $rowMemberInfo['Last_Name'],
"birthday"=> $rowMemberInfo['Birthday'],
"spousefirst"=> $rowMemberInfo['Spouse_First'],
"spouselast"=> $rowMemberInfo['Spouse_Last'],
"spousebirthday"=> $rowMemberInfo['Spouse_Birthday'],
"signuploc"=> $rowMemberInfo['Signup_Loc'],
"status"=> $rowMemberInfo['Status']
);
if (isset($rowMemberInfo['Anniversary'])) {
return $arr;
}else {
throw new SoapFault("Server","Unknown Member Number '$membernumber'.");
}
}
$server->AddFunction("doMyMemberSearch");
$server->handle();
?>
WSDL is implementation language agnostic. So it doesn’t matter if it was written in PHP, C#, Java or any other language.
You need to get the .wsdl file for the service. Usually you can get that by pointing your browser at the service URL with the addition of a query string ‘?WSDL’.
Example:
Once you have that you can use Apache CXF, Apache Axis2, Spring WS or any other web services framework to generate java client stub code.