即时通讯初学者编程和遵循使用PHP和SOAP使用Apache2.4 Web服务器的Web服务教程。 教程使用肥皂没有WSDL文件php肥皂 - SoapFault看起来像我们没有XML文档
客户:
<?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);
}
?>
服务器:在服务器中使用
<?php
require_once('Students.php');
$options = array("uri" => "http://localhost");
$server = new SoapServer(null, $options);
$server->setClass('Students');
$server->handle();
?>
类:
<?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 = array("Cooper", "Truman", "Johnson", "Briggs",
"Hayward", "Horne", "Hurley", "Moran", "Hill",
"Brennan", "Smith");
return $studentLN;
}
public function getStudentNames(){
$studentNames = "Dale Cooper, Harry Truman, Shelly Johnson, " .
"Bobby Briggs, Donna Hayward, Audrey Horne, " .
"James Hurley, Lucy Moran, Tommy Hill, " .
"Andy Brennan, John Smith";
return $studentNames;
}
}
?>
我不断收到此错误:
object(SoapFault)#2 (10) { ["message":protected]=> string(33) "looks like we got no XML document"....................
到目前为止我做了以下:在php.ini
- 延长= php_soap.dll未被注释(已删除)
- php_soap.dll是以php \分机发现
- 所有文件
- 没有拖尾空格之后或之前的PHP标记(据我可以告诉)
教程d被编码UTF-8无BOM oesnt使用wsdl文件,也许我需要更改php.ini中的更多设置?
可能是什么问题?
在此先感谢。
你是否重新启动Apache,因为取消注释'extension = php_soap.dll'这一行? –
是的,几次 – ND88