?今天在想使用soap開發(fā)相關(guān)接口給合作的公司調(diào)用,但是遇到了這個錯誤。
排查了很久,在google也查了很久,但都不是我所遇到的問題。不過我最終錯誤發(fā)現(xiàn)跟soapserver傳輸?shù)臄?shù)據(jù)量的大小有關(guān)系(不知道這個描述是否恰當(dāng))。當(dāng)我從數(shù)據(jù)庫取10條數(shù)據(jù),那么就可以很容易的使用soapclient獲取到數(shù)據(jù),但是當(dāng)我從數(shù)據(jù)庫里查詢1000條數(shù)據(jù)的時候就會報錯了(“Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in……”)!如果我直接運行person.class.php程序是可以顯示完整的xml文檔的。這根服務(wù)器的環(huán)境配置會有關(guān)系嗎?我對于soap認(rèn)識并不深,也只是現(xiàn)學(xué)現(xiàn)賣。希望有經(jīng)驗的前輩們可以指點一二。多謝了!以下是我的程序代碼:<?php//person.class.php文件class person{ public function getInfo() { $strGetList = 'SELECT * FROM information LIMIT 100'; $GLOBALS['le']->query($strGetList); $results = array(); $xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $xmlString .="<Data>\n"; while( $rows = $GLOBALS['le']->fetch_assoc() ) { $results[] = $rows;
} foreach($results as $key=>$val) { $xmlString .="<Rec ID='UU{$key}'>\n"; foreach($val as $k=>$v ) { if(strlen($v)>0) { $v = htmlspecialchars($v); $xmlString .=" <UU{$k}>$v</UU{$k}>\n";
}
} $xmlString .="</Rec>\n";
} $xmlString .="</Data>\n"; return $xmlString;
}
}//$p = new person;//echo $p->getInfo();//經(jīng)測試xml中可以顯示所有數(shù)據(jù)--- 分割線 ---<?php//server.php文件include("person.class.php");$server = new SoapServer(null,array('uri'=>'abcd','encoding'=>'UTF-8'));$server->setClass('person');$server->handle();
--- 分割線 ---<?php//client.php文件try{ $soap = new SoapClient(null,array( 'location'=>'http://192.168.1.126:102/server.php', 'uri'=>'abcd', 'encoding' => 'UTF-8',
)); $s1 =$soap->__soapCall('getInfo',array()); echo $s1;
} catch(Exction $e) { echo $e->getMessage();
}
查看完整描述