2014-02-06 27 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()函數。

謝謝,希望它能幫助別人。