简体   繁体   中英

SoapFault: looks like we got no XML document php error

I have an error I don't know solution for.

$response = $client->addcontract($docVar,$fVar);

This is error after this line of code: Error screenshot

$client=new SoapClient($wsdlUrl, array('cache_wsdl' => 0,'trace'=>1));
$docVar = new SoapVar($_POST, SOAP_ENC_OBJECT);
$file = array();
$file['file'] = base64_encode(file_get_contents($contract));
$file['filename'] = basename($contract);
$file['mime_type'] = 'application/pdf';
$fVar = new SoapVar($file, SOAP_ENC_OBJECT);

Maybe you can try to figure out this problem? Thank in advance!

Upd: There is no always_populate_raw_post_data in my php.ini file

Upd 2: Added this bunch of code:

try {
    $response = $client->addcontract($docVar, $fVar);
} catch(SoapFault $fault) {
    trigger_error("Error SOAP: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}

This is what it returns: Fatal error: Error SOAP: (faultcode: Client, faultstring: looks like we got no XML document)

Upd 3: Added this bunch of code in catch block

echo $client->__getLastRequest();
echo $client->__getLastResponse();

And added 'exceptions' => 1 for SoapClient. This is what it returns in __getLastResponse(): CException Undefined offset: 1 (/var/www/yii-1.0.9.r1396/framework/base/CApplication.php:608) (/var/www/yii-1.0.9.r1396/framework/web/services/CWebService.php:103)

Upd 4: found some code, there are first lines:

/**
* @param object post         
* @param object file         
* @return array      
* @soap
*/
public function addcontract($post,$file)
{            
    if(isset($post))
    {
        //We need to add the designer,partner,job,customer,document
        $model= Partners::model()->findByPk($post->partner_id);
        if($model === null)
        {
            $model = new Partners();
            $model->id=$post->partner_id;
        }

If I try to echo/var_dump something in this code, nothing happens. But if I break;, code do not go to my soap fault error.

Upd Last: I posted answer for this in separate answer post

So, I fixed the error. It was an error in $client->addcontract() function. I think it is too local error, so I want to advice just check if there are no errors in soap function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM