如何摆脱“未捕获的 SoapFault 异常:[客户端] 看起来我们没有 XML 文档...”错误
我正在尝试在服务器端使用 nusoap 开发动态站点的业务逻辑(因为我需要 wsdls,并且 PHP SOAP 扩展无法生成 wsdls),并在客户端使用 PHP SOAP 扩展。
但是,我什至无法正确登录和 getRole 功能。当我尝试调用客户端时,我收到以下消息
Uncaught SoapFault exception: [Client] looks like we got no XML document in [some paths]...
Wsdl 确实存在于服务器端,并且客户端确实读取了它(当我为 wsdl 输入错误的 url 时,我收到错误)。
有人可以帮忙吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
看起来您的客户端收到了一些无效的 XML - WSDL 本身或服务器返回的响应。尝试将
trace
选项设置为 TRUE 来调用客户端,并通过__getLastRequest()
和__getLastResponse()
方法。It looks like your client receives some invalid XML - either the WSDL itself or the response returned by the server. Try to invoke the client with the
trace
option set to TRUE and check the actual XML send/received via the__getLastRequest()
and__getLastResponse()
methods.我刚刚遇到了类似的问题;事实证明,我的服务正在
回显
一些调试数据。我删除了所有echo
行,效果很好。I just had a similar problem; turns out my service was
echo
ing out some debug data. I removed all of theecho
lines and it worked fine.不要忘记使用 try/catch 块:
Don't forget to use try/catch block:
我有同样的问题,我用这个解决了:
php中的服务器SOAP文件已使用BOM对utf8进行编码,导致apache在xml响应之前发回BOM标记(3个字节)。
使用 utf8 不带 BOM 标记对您的 php 文件肥皂服务器进行编码。
伊格纳西奥·古铁雷斯·托雷罗
I have the same problem, and I solved with this:
The server SOAP file in php has encode utf8 with BOM, causing apache send back the BOM mark (3 bytes) before the xml response.
Encode your php file soap server with utf8 WITH OUT BOM mark.
Ignacio Gutierrez Torrero
您的 SOAPServer 类末尾可能有一些尾随空格。请查看以下内容 博客文章了解更多信息:
Chances are you have some trailing whitespace at the end of your SOAPServer class. Please have a look at the following blog post for more information: http://arnekroeger.blogspot.com/2011/02/php-soap-error-looks-like-we-got-no-xml.html
就我而言,当我在“?>”之后包含带有空行的脚本时,就会出现此错误。标签。
删除这几行就可以解决问题
In my case, this error appeared when I included a script with blank lines after the "?>" label.
Delete these lines solves the problem
只需使用 trim() 作为参数即可。
Just use trim() for you args.
有时,BOM 可能会生成一些额外的字符,从而导致此类问题。
要检测是否有任何 UTF BOM,请参阅此 链接。
Some times a BOM can generate some extra characters which creates this type of problem.
To detect if there is any UTF BOM see this link.
我有同样的问题。通过在 php.ini 上将
always_populate_raw_post_data
设置为-1
解决了我的问题。我通过在选项上添加 "trace"=>1,"exceptions"=>1 并使用
try catch
并获取__getLastRequest()
和来发现这一点__getLastResponse()
I have same problem.my problem solved by set
always_populate_raw_post_data
to-1
on php.ini.I find out this by adding "trace"=>1,"exceptions"=>1 on options and use
try catch
and get__getLastRequest()
and__getLastResponse()
我有办法解决这个问题。这不是一个很好的解决方案,但它有效...
我如何无法在我的 mantis 服务器中进行任何更改,我决定这样做...
首先我必须使 SoapFault 保持沉默:
其次,我注意到有这三个尾随控制字符位于字符串的开头,因此我将其删除:
第三,我必须输入“pe>”在我的字符串的末尾,因为它不完整。
I have a way to solve this problem. This isn't a pretty solution, but it works...
How I can't do any change in my mantis server, I decided do this...
First I have to silence SoapFault:
Second, I've noted that there was this three trailing control char in begin of my string, so I've removed it:
Third, I've to put "pe>" in the end of my string, cause it was incomplete.
以下可能是某些用户遇到的问题。因为我已经经历过了。
对于最新的 nuSoap 版本,以下内容将解决您的问题:
中查找以下代码
在 nusoap.php的第 6132 行或此编号附近的内容
。并对其进行评论,
因为它仅用于调试目的。所以不用担心任何功能问题。
The below may be the problem for some users. because i have been through it.
For latest nuSoap version, the below will solve your problem :
FIND the below code in nusoap.php
in line 6132 or something around this no.
AND COMMENT IT
Since it just for debug purpose. so not to worry about any functionality issues.