致命错误:未捕获的SoapFault异常:[HTTP]发送HTTP SOAP失败

时间:2019-02-14 11:43:42

标签: php soap soap-client

我编写了一个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)失败吗?

非常感谢!

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并尝试了以下解决方案,它为我工作。 但我不知道您在标头中传递了哪些值。 请添加

messaging
  .getToken()
  .then(function(currentToken) {
    if (currentToken) {
      console.log(currentToken);
      // sendTokenToServer(currentToken);
      // updateUIForPushEnabled(currentToken);
    } else {
      // Show permission request.
      console.log(
        "No Instance ID token available. Request permission to generate one."
      );
      // Show permission UI.
      // updateUIForPushPermissionRequired();
      // setTokenSentToServer(false);
    }
  })
  .catch(function(err) {
    console.log("An error occurred while retrieving token. ", err);
    // showToken("Error retrieving Instance ID token. ", err);
    // setTokenSentToServer(false);
  });
})
.catch(function(err) {
  console.log("Unable to get permission to notify.", err);
});