PHP Soap请求在cli中工作,但在浏览器中不工作

PHP Soap请求在cli中工作,但在浏览器中不工作,php,curl,soap,exchange-server,exchangewebservices,Php,Curl,Soap,Exchange Server,Exchangewebservices,我们正在向microsoft exchange server 2016发出soap请求。来自cli脚本和soap客户端的请求正在工作。当从浏览器调用具有相同请求xml的相同脚本时,将无法工作 class testClass extends SoapClient { public $user = 'username'; public $password = 'password'; function __doRequest($request, $location,

我们正在向microsoft exchange server 2016发出soap请求。来自cli脚本和soap客户端的请求正在工作。当从浏览器调用具有相同请求xml的相同脚本时,将无法工作

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);
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

这是由于文件权限问题。我在tmp文件夹中添加了cookies.json文件,并授予其可写权限,并更改了SoapClient类中的cookies.json路径。

您使用的是哪台服务器?apache、nginx或iis?apache。如果您能提供帮助,我们将不胜感激。这可能是文件权限问题吗?在每种情况下,您可能以不同的用户身份运行脚本。请尝试为cookies.json编写的tmp文件夹。谢谢@Progrock您的答案帮助。@Progrock您可以添加答案。正如你在评论中提到的那样,我为cookies.json创建了一个文件夹,并授予了world write file权限,它成功了。