带有肥皂的PHP - 文档末尾的额外内容
我开始使用SOAP学习PHP,但是在我的初始测试中,要查看它是如何工作的,我会遇到此错误,
Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't load from 'http://localhost/M07_ACT5/servidor.php?wsdl' :
Extra content at the end of the document in C:\xampp\htdocs\M07_ACT5\cliente.php:4
Stack trace:
#0 C:\xampp\htdocs\M07_ACT5\cliente.php(4):
SoapClient->__construct('http://localhos...')
#1 {main} thrown in C:\xampp\htdocs\M07_ACT5\cliente.php on line 4
它将其扔到Soapclient构造函数上,但是 extra extrue content 是什么?
我确保我的php.ini文件允许使用肥皂。
Client.php
<?php
require_once("lib/nusoap.php");
$client = new soapclient('http://localhost/M07_ACT5/servidor.php?wsdl'); <---- HERE
$result = $client->holaMundo();
echo $result;
?>
这是我用于此测试的Server.php文件。我检查了名称空间是否正确,但它在正确的文件夹中。
<?php
require_once("lib/nusoap.php");
$namespace = "http://localhost/M07_ACT5/servidor.php";
$server = new soap_server();
$server->configureWSDL("MiServicioWeb", $namespace);
$server->schemaTargetNamespace = $namespace;
$server->soap_defencoding = 'UTF-8';
function holaMundo(){
return "Hola, mundo!!!";
}
$server->register(
'holaMundo',
array(),
array('return'=>'xsd:string'),
$namespace,
false,
'rpc',
'encoded',
'Método HolaMundo '
);
$server->service(file_get_contents("php://input"));
?>
I'm starting to learn PHP with SOAP, but during my initial test to see how it works I run into this error
Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't load from 'http://localhost/M07_ACT5/servidor.php?wsdl' :
Extra content at the end of the document in C:\xampp\htdocs\M07_ACT5\cliente.php:4
Stack trace:
#0 C:\xampp\htdocs\M07_ACT5\cliente.php(4):
SoapClient->__construct('http://localhos...')
#1 {main} thrown in C:\xampp\htdocs\M07_ACT5\cliente.php on line 4
It throws it on the soapclient constructor line, but what is the extra content?
I made sure that my php.ini file allows the use of SOAP.
Client.php
<?php
require_once("lib/nusoap.php");
$client = new soapclient('http://localhost/M07_ACT5/servidor.php?wsdl'); <---- HERE
$result = $client->holaMundo();
echo $result;
?>
This is my server.php file for this test. I checked if the name space is right but it's in the correct folder.
<?php
require_once("lib/nusoap.php");
$namespace = "http://localhost/M07_ACT5/servidor.php";
$server = new soap_server();
$server->configureWSDL("MiServicioWeb", $namespace);
$server->schemaTargetNamespace = $namespace;
$server->soap_defencoding = 'UTF-8';
function holaMundo(){
return "Hola, mundo!!!";
}
$server->register(
'holaMundo',
array(),
array('return'=>'xsd:string'),
$namespace,
false,
'rpc',
'encoded',
'Método HolaMundo '
);
$server->service(file_get_contents("php://input"));
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论