2014-02-06 30 views
0

我使用螳螂Bug跟踪SOAP API,可惜每次都返回到我的消息像螳螂Bug跟踪SOAP API响应XML错误

looks like we got no XML document”,

跟踪的上一个响应后,我得到了以下消息

"<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> 
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Issue does not exist.</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>" 

我希望,我得到XML respose回来,看来是有另外的在开始""字符。

任何线索或帮助将是伟大的,在删除这些字符。

连接到MANTIS SOAP API服务器

<?php 
    $c = new \SoapClient("http://dev06/api/soap/mantisconnect.php?wsdl", array('trace'=> true, 'encoding'=>' UTF-8', 'soap_version'=>1.2)); 
    $username = "xxxxx"; 
    $password = "xxxxx"; 
    try { 
     $c->mc_issue_get(trim($username), trim($password), 2331); 
    } catch (SoapFault $exception) { 
     var_dump($c->__getLastResponse()); 
    } 
    ?> 
+0

请提供更多信息,如Mantis版本和连接到螳螂的源代码。 – libregeek

+0

嗨,感谢您的回复。我正在使用最新版本的Mantis 1.2.15。请在上面找到连接到螳螂SOAP api服务器的代码。 – bharatesh

回答

0

我没有看到你的代码中的任何问题,它完美的作品在我的环境稍作修改代码:

$c = new \SoapClient("http://localhost/demo/mantisbt-1.2.15/api/soap/mantisconnect.php?wsdl", array('trace'=> true, 'encoding'=>' UTF-8', 'soap_version'=>SOAP_1_2)); 
    $username = "XXXXXXXX"; 
    $password = "XXXX"; 
    try { 
     $issue = $c->mc_issue_get(trim($username), trim($password), 31); 
     var_dump($issue); 
    } catch (SoapFault $exception) { 
     var_dump($c->__getLastResponse()); 
    } 

可能是soap_version,所以可能你可以尝试soap_version = SOAP_1_1

+0

感谢您的回复。无论如何,我仍然遇到同样的问题。它与客户端设置有关。 – bharatesh

+0

客户端设置是什么意思? – libregeek

+0

可能是浏览器设置? – bharatesh

0

哦......!

终于得到了它的解决方案。它非常简单。

首先螳螂SOAP API代码库中可能包含20000多行代码。我认为有些人正在打印一些BOM字符。

所以最好的解决办法是,只需要使用下面的函数,

ob_clean(); 

该功能必须在

/library/nusoap/nusoap.php 

使用,因为这个文件有

send_response()

即打印有效载荷,所以只需在beginnin处使用ob_clean() g的send_response()函数。

谢谢,希望它能帮助别人。