嗨我試圖通過CURL發送POST請求,但它拋出一個錯誤,說
「無法連接到qaservices.carrental.com:443;沒有錯誤」。驗證卷曲HTTP發佈
的用戶名和密碼已經被包含在一個XML文件
<?php
$filename = 'c:/v.xml';
$data = file_get_contents($filename);
$url = 'https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071';
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url);
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_setopt($soap_do, CURLOPT_POST, true);
curl_setopt($soap_do, CURLOPT_HEADER, 0);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
if (curl_errno($soap_do))
{
$result = 'ERROR -> ' . curl_errno($soap_do) . ': ' . curl_error($soap_do);
}
else
{
$returnCode = (int)curl_getinfo($soap_do, CURLINFO_HTTP_CODE);
switch($returnCode)
{
case 200:
break;
default:
$result = 'HTTP ERROR -> ' . $returnCode;
break;
}
}
curl_close($ch);
echo $result;
?>
SOAP頭當我嘗試發送的HttpWebRequest在vb.net這工作。在vb.net代碼副本是
doc.Load("c:/v.xml")
Dim content As String = doc.InnerXml
Dim urlEncoded As String = content
Dim encodedRequest As Byte() = New ASCIIEncoding().GetBytes(urlEncoded)
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071"), HttpWebRequest)
request.Method = "POST"
request.Accept = "*/*"
request.ContentType = "application/x-www-form-urlencoded"
' request.UserAgent = "Custom REST client v1.0"
request.ContentLength = encodedRequest.Length
request.Proxy.Credentials = CredentialCache.DefaultCredentials
Dim reqStream As Stream = request.GetRequestStream()
reqStream.Write(encodedRequest, 0, encodedRequest.Length)
reqStream.Flush()
reqStream.Close()
Dim response As HttpWebResponse = (request.GetResponse())
Dim responseStream As Stream = response.GetResponseStream()
Dim streamReader As New StreamReader(responseStream)
Dim responseContent As String = streamReader.ReadToEnd
我認爲它做在設置代理證書的東西任何人都可以請指導我在正確的道路
我試過了,但仍然沒有工作 – Neo
粘貼的print_r的'輸出(curl_getinfo($ soap_do));' –
Array([url] => https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071 [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.498 [namelookup_time] => 0.499 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array()[primary_ip] = > 170。 225.0.83 [primary_port] => 443 – Neo