通过 SOAP 从 PHP 调用 Moodle 函数
我在开始通过提供的 SOAP Web 服务将 PHP 脚本连接到 Moodle 2.0 时遇到困难。由于对 SOAP 了解不多,我想我只需连接并从那里开始。但是,我什至无法连接......
$soap=new SoapClient(
'http://mymoodleserver/webservice/xmlrpc/server.php?wstoken=asdfasdfasdfasdfasdf',
array(
'trace'=>1,
'exceptions'=>true,
'cache_wsdl'=>WSDL_CACHE_NONE
)
);
这返回:
致命错误:未捕获 SoapFault 异常:[WSDL] SOAP-ERROR:正在解析 WSDL:无法加载...
如果我直接访问此 URL,则不会返回任何数据。用 Fiddler 查看它表明服务器确实返回了 0 的内容长度。
我找不到任何关于此的文档...有 其他协议的文档。
我假设 SoapClient 期望一些 WSDL 来定义哪些函数可用的。我有这些函数和参数的列表(不感谢官方文档页面 )。我如何指示 SoapClient 不用担心 WSDL 并继续?
我检查了 Moodle 服务器上 PHP 错误日志中的错误,结果显示是干净的。
I am having difficulty getting started with interfacing my PHP script to Moodle 2.0 over the SOAP Web Service provided. Not knowing much about SOAP, I figured I would simply connect and go from there. However, I can't even get connected...
$soap=new SoapClient(
'http://mymoodleserver/webservice/xmlrpc/server.php?wstoken=asdfasdfasdfasdfasdf',
array(
'trace'=>1,
'exceptions'=>true,
'cache_wsdl'=>WSDL_CACHE_NONE
)
);
This returns:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load...
If I were to go to this URL directly, no data is returned. Looking at it with Fiddler shows that the server does indeed return a Content-Length of 0.
There isn't any documentation on this that I could find... there is documentation for other protocols however.
I am assuming that the SoapClient is expecting some WSDL to define what functions are available. I have a list of those functions and parameters (no thanks to the official documentation page). How can I instruct SoapClient to not worry about the WSDL and carry on?
I have checked for errors in the PHP error log on the Moodle server, and it turned up clean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用非wsdl模式的方法是将其添加到uri
ofocurse中,使用trace然后查找getlastrequest和getlastresponse
http://www.php.net/manual/en/soapclient.getlastrequest.php
使用 xmlspy 方便调试。
The way to use the non wsdl mode is to add it to the uri
Ofocurse, use trace and then look for getlastrequest and getlastresponse
http://www.php.net/manual/en/soapclient.getlastrequest.php
Use xmlspy for easy debugging.
关键在于错误,因此我开始查看 Moodle 文档,了解会发生什么,而不是 WSDL。
检查 SoapClient 和 Moodle 文档,您可以看到 Moodle 不提供 WSDL 因此您需要在 中使用 SoapClient非 WSDL 模式。
The key is in the error, so I started looking at the documentation for Moodle knowing what to expect, no WSDL.
Check the documentation for SoapClient and the documentation for Moodle as you can see Moodle doesnt offer WSDL so you need to use the SoapClient in non-WSDL mode.