Wir machen Seife Anfrage an Microsoft Exchange Server 2016. Anfrage von CLI-Skripten und Soap-Clients arbeiten. Dasselbe Skript mit derselben Anfrage-XML funktioniert nicht, wenn es vom Browser aufgerufen wird.PHP Soap-Anfrage funktioniert in CLI, aber nicht im Browser
class testClass extends SoapClient {
public $user = 'username';
public $password = 'password';
function __doRequest($request, $location, $action, $version, $one_way = NULL) {
$headers = array(
'Method: POST',
'Connection: Keep-Alive',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: "'.$action.'"',
);
$this->__last_request_headers = $headers;
$request = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<DeleteItem DeleteType="HardDelete" SendMeetingCancellations="SendToAllAndSaveCopy" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ItemIds>
<t:ItemId Id="AAANAG9wQHRmaHMubHUuc2UARgAAAAAAoeCyBeBA7EGXcncI4cCeZwcAnd+iJ87BLkGneeHHldhNdAAAABB5VAAAnd+iJ87BLkGneeHHldhNdAAA1wzUcAAA"/>
</ItemIds>
</DeleteItem>
</soap:Body>
</soap:Envelope>';
$ch = curl_init($location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.json');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.json');
$response = curl_exec($ch);
if(!trim($response) == "")
return $response;
else
return "no resp";
unlink("cookies.json");
}
}
$result = $client->DeleteItem($DeleteItem);
var_dump($result);
Wir haben überprüft und sichergestellt, dass wir openssl, curl, soapclient extensions haben. Wir erhalten den folgenden Fehler beim Anfordern von Browser.
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in
C:\xampp\htdocs\test\wsdl2phpgenerator\xmltfhs\test.php:140 Stack trace: #0
C:\xampp\htdocs\test\wsdl2phpgenerator\xmltfhs\test.php(140): SoapClient->__call('DeleteItem', Array) #1
C:\xampp\htdocs\test\wsdl2phpgenerator\xmltfhs\test.php(140): testClass->DeleteItem(Object(DeleteItemType)) #2 {main}
thrown in C:\xampp\htdocs\test\wsdl2phpgenerator\xmltfhs\test.php on line 140
Welchen Server verwenden Sie? Apache, Nginx oder Iis? –
Apache. Es wäre dankbar, wenn Sie helfen könnten. –
Könnte dies ein Dateiberechtigungsproblem sein? Sie können das Skript in jedem Fall als ein anderer Benutzer ausführen. Versuchen Sie einen tmp-Ordner, der für cookies.json schreibbar ist. – Progrock