phpsoapbackendsoap-client

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


Solution

  • I fixed the error. It was an error in the addcontract() method.

    I think it is too local of an error, so I want to offer advice: just check if there are no errors in the soap function.