2016-06-23 12 views
2

Microsoft Exchange Server 2016にSOAPリクエストを送信しています.cliスクリプトとSOAPクライアントからのリクエストが機能しています。ブラウザから呼び出されたときに、同じリクエストxmlを持つ同じスクリプトが機能しません。PHP Soapリクエストはブラウザでは動作しませんが、ブラウザでは動作しません

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

openssl、curl、soapclient拡張があることを確認し、確認しました。 ブラウザからのリクエストに次のエラーが発生しています。

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 
+0

お使いのサーバーはどれですか? apache、nginxまたはiis? –

+0

Apache。もしあなたが手伝ってくれれば幸いです。 –

+1

これはファイルアクセス権の問題ですか?それぞれのケースで異なるユーザーとしてスクリプトを実行している可能性があります。 cookies.jsonの書き込み可能なtmpフォルダを試してみてください。 – Progrock

答えて

0

これはファイルアクセス権の問題によるものです。 cookies.jsonファイルをtmpフォルダに追加し、書き込み可能な権限を与え、SoapClientクラスのcookies.jsonパスを変更しました。

関連する問題