小编Nex*_*ddo的帖子

php soap - SoapFault看起来我们没有XML文档

我是编程的初学者,并使用Apache2.4 Web服务器使用php和soap进行Web服务教程.本教程使用不带wsdl文件的soap

客户:

<?php
$options = array(
    "location" => "http://localhost/web-services/soap_service.php",
    "uri" => "http://localhost", 
    "trace" => 1,
);

try {
    $client = new SoapClient(null, $options);
    $students = $client->getStudentNames();
    echo $students;
} catch(SoapFault $ex) {
    echo var_dump($ex);
}
?>
Run Code Online (Sandbox Code Playgroud)

服务器:

<?php
require_once('Students.php');

$options = array("uri" => "http://localhost");
$server = new SoapServer(null, $options);
$server->setClass('Students');
$server->handle();
?>
Run Code Online (Sandbox Code Playgroud)

服务器中使用的类:

<?php
class Students{

    public function getStudentFirstName(){

        $studentFN = array("Dale", "Harry", "Shelly", "Bobby",
                "Donna", "Audrey", "James", "Lucy", "Tommy",
                "Andy", "John");

        return $studentFN;

    }

    public function getStudentLastName(){

        $studentLN …
Run Code Online (Sandbox Code Playgroud)

php soap web-services

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×1

soap ×1

web-services ×1