我编写了一个PHP脚本,它执行SOAP请求以发送一些数据并使用PHP 7.2.14中的soap_client上传base64binary
。
在使用少量数据(小文件<60 Kb)执行SOAP请求后,请求将通过。如果我添加一个更大的文件来上传(> 80 Kb),请求将失败并出现此错误:
Fatal error: Uncaught SoapFault exception: [HTTP] Failed Sending HTTP SOAP
。
我检查了服务器上的default_socket_timeout
并增加了它。我也尝试了base64_econde
字符串,但SOAP已经自己编码了。
我的代码:
//WS SETTINGS
$wsdl = "https://ws.eye-move.nl/WoningDocument.asmx?WSDL";
$ns = 'http://ws.eye-move.nl/WoningDocument';
// SOAP client
$params = array ('trace' => 1, 'exceptions' => 1, "connection_timeout" => 180);
$client = new SoapClient($wsdl, $params);
//COLLECT DATA FOR UPLOADING
$RecID = '34244701';
$filename = 'Testfile-'.date("Y-m-d H:i:s").'.pdf';
$filecontent = file_get_contents('temp/test.pdf');
//SET HEADERS
$headerBody = array(
'Username' => $login,
'Password' => $password,
'Customer' => $partnerID
);
$header = new SoapHeader($ns, 'AuthHeader', $headerBody);
$client->__setSoapHeaders($header);
$data = array(
'WoningID' => $RecID,
'WoningDocumentBestand' => array('Bestandsnaam'=>$filename,'Bestand'=>$filecontent),
'WoningDocumentType' => 'DocumentType',
'Omschrijving' => 'Description',
'Volgorde' => '1'
);
$result = $client->Add(array('Gegevens' => $data));
完全豁免:
Fatal error: Uncaught SoapFault exception: [HTTP] Failed Sending HTTP SOAP request in /var/www/vhosts/acceptatie.nl/httpdocs/sendrapport3.php:65 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'ws.eye-m...', 'ws.eye-m...', 1, 0) #1 /var/www/vhosts/acceptatie.nl/httpdocs/sendrapport3.php(65): SoapClient->__call('Add', Array) #2 {main} thrown in /var/www/vhosts/acceptatie.nl/httpdocs/sendrapport3.php on line 65
我在第65行写的代码如下:
$result = $client->Add(array('Gegevens' => $data));
任何想法为什么小文件将成功发送和更大的文件(> 80 Kb)将失败?
非常感谢!
我遇到了同样的问题并尝试了下面的解决方案,它对我有用。但我不知道你在标题中传递了哪些值。请加
#) libxml_disable_entity_loader(false); // above the WS SETTINGS and try it.