如何摆脱“未捕获的 SoapFault 异常:[客户端] 看起来我们没有 XML 文档...”错误

发布于 2024-08-26 20:18:01 字数 348 浏览 9 评论 0 原文

我正在尝试在服务器端使用 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 时,我收到错误)。

有人可以帮忙吗?

I'm trying to develop business logic for a dynamic site using nusoap on server side (because I need wsdls, and PHP SOAP extension can't generate wsdls), and PHP SOAP extenstion on client side.

However, I can't get even login and getRole functions right. When i try to invoke client, I get following message

Uncaught SoapFault exception: [Client] looks like we got no XML document in [some paths]...

Wsdl does exist on server side, and client does read it (when I put wrong url for wsdl, I get an error).

Can anyone help??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

终陌 2024-09-02 20:18:01

看起来您的客户端收到了一些无效的 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.

二手情话 2024-09-02 20:18:01

我刚刚遇到了类似的问题;事实证明,我的服务正在回显一些调试数据。我删除了所有 echo 行,效果很好。

I just had a similar problem; turns out my service was echoing out some debug data. I removed all of the echo lines and it worked fine.

不忘初心 2024-09-02 20:18:01

不要忘记使用 try/catch 块:

try {
    var_dump($client->foo());
} catch (Exception $e) {
    echo($client->__getLastResponse());
    echo PHP_EOL;
    echo($client->__getLastRequest());
}

Don't forget to use try/catch block:

try {
    var_dump($client->foo());
} catch (Exception $e) {
    echo($client->__getLastResponse());
    echo PHP_EOL;
    echo($client->__getLastRequest());
}
叫嚣ゝ 2024-09-02 20:18:01

我有同样的问题,我用这个解决了:

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

凑诗 2024-09-02 20:18:01

您的 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

∞觅青森が 2024-09-02 20:18:01

就我而言,当我在“?>”之后包含带有空行的脚本时,就会出现此错误。标签。

删除这几行就可以解决问题

In my case, this error appeared when I included a script with blank lines after the "?>" label.

Delete these lines solves the problem

傲性难收 2024-09-02 20:18:01

只需使用 trim() 作为参数即可。

$objectRequette = trim($_POST['Requette']) ;
$client = new SoapClient(null, array(
    'location' => 'http://your.php',
    'uri'=>'your option',
));
$result = $client->__soapCall('Misyka', array("$objectRequettea"));

Just use trim() for you args.

$objectRequette = trim($_POST['Requette']) ;
$client = new SoapClient(null, array(
    'location' => 'http://your.php',
    'uri'=>'your option',
));
$result = $client->__soapCall('Misyka', array("$objectRequettea"));
×眷恋的温暖 2024-09-02 20:18:01

有时,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.

仲春光 2024-09-02 20:18:01

我有同样的问题。通过在 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()

一场春暖 2024-09-02 20:18:01

我有办法解决这个问题。这不是一个很好的解决方案,但它有效...

我如何无法在我的 mantis 服务器中进行任何更改,我决定这样做...

首先我必须使 SoapFault 保持沉默:

try {
    $client = new SoapClient('http://www.mymantisaddress.com/api/soap/mantisconnect.php?wsdl', array('trace'=> 1, 'exceptions' => 0));
    $result = $client->__soapCall($function_name, $args);
} catch (SoapFault $e) {
    //$result = array(
    //    'erro' => $e->faultstring
    //);
}

其次,我注意到有这三个尾随控制字符位于字符串的开头,因此我将其删除:

$str = substr($client->__getLastResponse(), 3) . "pe>";
print $str;

第三,我必须输入“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:

try {
    $client = new SoapClient('http://www.mymantisaddress.com/api/soap/mantisconnect.php?wsdl', array('trace'=> 1, 'exceptions' => 0));
    $result = $client->__soapCall($function_name, $args);
} catch (SoapFault $e) {
    //$result = array(
    //    'erro' => $e->faultstring
    //);
}

Second, I've noted that there was this three trailing control char in begin of my string, so I've removed it:

$str = substr($client->__getLastResponse(), 3) . "pe>";
print $str;

Third, I've to put "pe>" in the end of my string, cause it was incomplete.

鹊巢 2024-09-02 20:18:01

以下可能是某些用户遇到的问题。因为我已经经历过了。

对于最新的 nuSoap 版本,以下内容将解决您的问题:

中查找以下代码

$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); 

在 nusoap.php的第 6132 行或此编号附近的内容

。并对其进行评论,

// $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");

因为它仅用于调试目的。所以不用担心任何功能问题。

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

$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); 

in line 6132 or something around this no.

AND COMMENT IT

// $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");

Since it just for debug purpose. so not to worry about any functionality issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文