首页 > 代码库 > 解决SOAP错误[Client] looks like we got no XML document

解决SOAP错误[Client] looks like we got no XML document

由于服务器配置不规范等等原因都会导致此类错误,解决:

http://my.oschina.net/cart/

class SoapClientNew extends SoapClient  
{  
    public function __doRequest($request, $location, $action, $version, $one_way = 0)  
    {  
        $request = parent::__doRequest($request, $location, $action, $version, $one_way);  
        
        $start = strpos($request, ‘<soap‘);//根据实际情况做处理。。。,如果是<?xml开头,改成<?xml
        $end = strrpos($request, ‘>‘);  
        return substr($request, $start, $end-$start+1);  
    }  
}
调用:
$client = new SoapClientNew($url);



完美解决!