0

我有下面的 php webservice 代码,我想做什么,这样我就可以在 java 中调用这个 web 服务。我需要先生成wsdl吗?然后用 wsdl 生成 java web 服务存根?我怎么能在java中调用它。以及我需要使用什么工具。谢谢你。

<?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();
?>
4

1 回答 1

0

WSDL 与实现语言无关。所以不管它是用 PHP、C#、Java 还是任何其他语言编写的。您需要获取服务的 .wsdl 文件。通常,您可以通过将浏览器指向服务 URL 并添加查询字符串“?WSDL”来获得它。

例子:

http://www.example.com/theWebService?WSDL

一旦有了这些,您就可以使用 Apache CXF、Apache Axis2、Spring WS 或任何其他 Web 服务框架来生成 Java 客户端存根代码。

于 2012-09-07T19:53:41.477 回答