[英]Call SOAP method via CURL in PHP,call require client authentication
概述:
該代碼是關於使用 SOAP 和 Curl 調用 escreen Web 服務,並且需要客戶端身份驗證。 目前我沒有得到任何結果,只有 HTTP 403 和 500 錯誤。 該調用要求客戶端身份驗證證書位於調用站點上。
代碼:
$content = "<TicketRequest>
<Version>1.0</Version>
<Mode>Test</Mode>
<CommitAction></CommitAction>
<PartnerInfo>
<UserName>xxxxxxxxxx</UserName>
<Password>xxxxxxxxxxx</Password>
</ PartnerInfo>
<RequestorOrderID></RequestorOrderID>
<CustomerIdentification>
<IPAddress></IPAddress>
<ClientAccount>xxxxxxxxxx</ClientAccount>
<ClientSubAccount>xxxxxxxxxx</ClientSubAccount>
<InternalAccount></InternalAccount>
<ElectronicClientID></ElectronicClientID>
</CustomerIdentification>
<TicketAction>
<Type></Type>
<Params>
<Param>
<ID>4646</ID>
<Value></Value>
</Param>
</Params>
</TicketAction>
</TicketRequest>";
$wsdl = "https://services.escreen.com/SingleSignOnStage/SingleSignOn.asmx";
$headers = array( "Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
// "SOAPAction: \"\"",
"Content-length: ".strlen($content),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, '1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1');
//curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""'));
curl_setopt($ch, CURLOPT_CAPATH, '/home/pps/');
curl_setopt($ch, CURLOPT_CAINFO, '/home/pps/authority.pem');
curl_setopt($ch, CURLOPT_SSLCERT, 'PROTPLUSSOL_SSO.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxxxxxxxx');
$output = curl_exec($ch);
// Check if any error occured
if(curl_errno($ch))
{
echo 'Error no : '.curl_errno($ch).' Curl error: ' . curl_error($ch);
}
print_r($output);
問題:
我需要調用 RequestTicket 方法並將 XML 字符串傳遞給它。 我不知道在這里怎么做(傳遞方法名稱來調用)。
對於客戶端身份驗證,他們給了我們三個證書,一個根證書,一個中間證書和一個客戶端身份驗證證書 PROTPLUSSOL_SSOpem(它是一個 .pfx 文件)。 由於我們在 linux 上,我們將它們轉換為 pem 。 在 curl 調用中,我找不到如何同時包含根證書和中間證書的方法,因此我通過創建一個新的 pem 文件並復制中間證書和根證書並將其命名為 authority.pem 來組合它們。 我不確定它是否有效,並希望得到您的意見。
對於當前代碼,我收到錯誤錯誤號:77 卷曲錯誤:錯誤設置證書驗證位置:CAfile:/home/pps/authority.pem CApath:/home/pps/
如果我禁用 curl 錯誤消息,我會看到頁面標題為 403 - Forbidden 的空白頁面。 訪問被拒絕。
如果我注釋掉 CURLOPT_CAPATH 和 CURLOPT_CAINFO 行,它會給出 http 500 錯誤頁面,消息作為內容,下面是頂部。
HTTP/1.1 500 內部服務器錯誤。 緩存控制:私有內容類型:文本/html 服務器:Microsoft-IIS/7.5 X-AspNet-版本:1.1.4322 X-Powered-By:ASP.NET 日期:2010 年 9 月 2 日星期四 14:46:38 GMT內容長度:1208
如果我注釋掉如上以及 CURLOPT_SSLCERT 和 CURLOPT_SSLCERTPASSWD 它會給出 403 錯誤,消息作為內容。
所以我會請求你通過指出當前代碼有什么問題來幫助我。
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.