我写了一个 php web 服务。功能如下:
function get_device_info(){
$conn= mysql_connect("localhost", "admin", "123456") or die("Could not connect: " . mysql_error());
mysql_select_db('devices',$conn);
$sql="select id,description,hostname,status_rec_date,availability from host";
$query=mysql_query($sql);
while($myrow = mysql_fetch_array($result)){
$host_msg[$i]=$myrow;
$i++;
}
return $host_msg;
mysql_close($conn);
}
然后我用java编写了soap客户端来调用这个web服务。
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class javasoapclient {
public static void main(String[] args) throws ServiceException, MalformedURLException, RemoteException {
String serviceUrl = "http://192.168.1.44/webservices/serverSoap.php";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceUrl));
call.setOperationName("get_device_info");
String reVal = call.invoke(new Object[] {}).toString();
System.out.println(reVal);
}
}
它无法获取数组。我是 PHP 新手。任何人都可以帮忙吗?
先谢谢了!</p>