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的新手。有人可以帮忙吗?
提前致谢!
答案 0 :(得分:0)
这不是SOAP的工作原理。 SOAP具有独特的结构:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>
你要归的只是一个简单的数组。
为了在java中获取此数组,最好使用HttpClient