2013-07-12 81 views
0

我目前正在測試和玩我的本地主機上的web服務。我在程序的客戶端調用中遇到了「SoapFault異常:[客戶端]看起來像我們沒有XML文檔」,我似乎無法找到原因。PHP-SOAP SoapFault異常:[客戶端]看起來像我們沒有XML文檔

我已經將編碼更改爲沒有BOM的UTF8(正如其他問題中所建議的那樣),但仍然沒有任何結果。我認爲這可能是因爲我在wsdl規範中使用的複雜類型。

下面是我認爲問題的WSDL的一部分:

<types> 
<xsd:schema targetNamesace="urn:consulta"> 
    <xsd:simpleType name="codigo"> 
     <xsd:restriction base="xsd:string"> 
      <xsd:minLength value="1"/> 
      <xsd:maxLength value="255"/> 
     </xsd:restriction> 
    </xsd:simpleType> 
    <xsd:simpleType name="designacao"> 
     <xsd:restriction base="xsd:string"> 
      <xsd:minLength value="1"/> 
      <xsd:maxLength value="255"/> 
     </xsd:restriction> 
    </xsd:simpleType> 
    <xsd:simpleType name="unidades"> 
     <xsd:restriction base="xsd:string"> 
      <xsd:minLength value="1"/> 
      <xsd:maxLength value="255"/> 
     </xsd:restriction> 
    </xsd:simpleType> 
    <xsd:simpleType name="quantidade"> 
     <xsd:restriction base="xsd:decimal"> 
      <xsd:minLength value="2"/> 
      <xsd:maxLength value="18"/> 
     </xsd:restriction> 
    </xsd:simpleType> 
    <xsd:simpleType name="referencia"> 
     <xsd:restriction base="xsd:string"> 
      <xsd:minLength value="1"/> 
      <xsd:maxLength value="255"/> 
     </xsd:restriction> 
    </xsd:simpleType> 
    <xsd:complexType name="MapaQuantidades"> 
     <xsd:sequence> 
      <xsd:element name="codigo" type="tns:codigo"/> 
      <xsd:element name="designacao" type="tns:designacao"/> 
      <xsd:element name="unidades" type="tns:unidades"/> 
      <xsd:element name="quantidade" type="tns:quantidade"/> 
     </xsd:sequence> 
    </xsd:complexType> 
</xsd:schema> 
</types> 

而且我在客戶端使用的代碼:

$wsdl= "...."; 

$soap_options = array(
    'trace'  => 1,  // traces let us look at the actual SOAP messages later 
    'exceptions' => 1); 

$cliente = new SoapClient($wsdl, $soap_options); 

$mapaQtds = new StdClass(); 
$mapaQtds->MapaQuantidades = new StdClass(); 
$mapaQtds->MapaQuantidades->codigo = 'Codigo WS'; 
$mapaQtds->MapaQuantidades->designacao = 'Designacao WS'; 
$mapaQtds->MapaQuantidades->unidades = 'Unidades WS'; 
$mapaQtds->MapaQuantidades->quantidade = 20; 

$soapstruct = new SoapVar($mapaQtds, SOAP_ENC_OBJECT); 

$referencia = "Referencia WS"; 
$designacao = "Designacao Principal"; 

try{ 

    $valor = $cliente->create_consulta($referencia, $designacao, $soapstruct); 
    //echo "Resultado = " . $valor; 
    echo "REQUEST:\n" . $client->__getLastRequestHeaders() . "\n"; 

}catch(SoapFault $e){ 
    var_dump($e); 
} 

目前,該服務器上的功能只返回true ...但似乎該程序甚至沒有到達服務器。它在$ client-> create_consulta中「死亡」。任何想法爲什麼發生這種情況?

完整的錯誤是:

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document  in C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php:30 Stack trace: #0 C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php(30): SoapClient->__call('create_consulta', Array) #1 C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php(30): SoapClient->create_consulta('Referencia WS', 'Designacao Prin...', Object(SoapVar)) #2 {main} thrown in C:\xampp\htdocs\Integration\Agregation\WSConsultaClient.php on line 30 

Thx提前, CR

回答

0

檢查您的服務器的代碼,我有同樣的問題,我解決它消除每一個回聲,>,和HTML代碼?在頁面中,你的server.php必須是空白頁

+0

你可能會剪切並粘貼適用的代碼,你做了什麼修復它? –

相關問題