我正在laravel上的一个小网站上工作,我从webservices中检索了一些数据并在我的localhost上使用它,一切都很好,然后我将它上传到我的服务器3上,所有这些都无法发送请求。
服务器1 = http://testing2.vire-news.com/(主持人:godaddy)
服务器2 = http://testing.asmani.pk/(主机:hostgator)
如果你点击搜索,它将不会从webservice给你结果。
我已经在stackoverflow上搜索了所有类型CURLOPT_POST
,CURLOPT_FOLLOWLOCATION
等所有内容并且没有任何效果
它给出了错误
在服务器2上“无法连接到emexonline.com端口3000:拒绝连接”
它保持连接然后超时。 我制作了一个相同代码的简单php文件来测试laravel环境,它也无法正常工作。
注意:我已经测试了其他curl web服务,例如facebook和twitter API,他们都在这些服务器上工作正常,我已经联系了网络服务提供商,他们说一切都很好,其他客户也在使用他们的webservice没有任何问题。
这是我从XML数据中删除用户名和密码的代码。 一切正常在localhost和服务器上工作,它给出错误,所有其他功能工作正常,只有webservice没有连接。
$xml_data = '<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<SearchPart xmlns="http://emexonline.com:3000/MaximaWS/">
<Customer>
<UserName>username</UserName>
<Password>password</Password>
<SubCustomerId>0</SubCustomerId>
<CustomerId>20879</CustomerId>
</Customer>
<DetailNum>'.$Request->search.'</DetailNum>
<ShowSubsts>0</ShowSubsts>
</SearchPart>
</soap12:Body>
</soap12:Envelope>
';
$headers = array(
"POST /MaximaWS/Service.asmx HTTP/1.1",
"Host: emexonline.com",
"Content-Type: application/soap+xml; charset=utf-8",
"SOAPAction: \"http://dpd.com/common/service/LoginService/2.0/getAuth\"",
"Content-Length: ".strlen($xml_data)
);
$url = 'http://emexonline.com:3000/MaximaWS/Service.asmx';
$curll = curl_init();
curl_setopt($curll, CURLOPT_URL,$url);
curl_setopt($curll, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curll, CURLOPT_TIMEOUT, 30);
curl_setopt($curll, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curll, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curll, CURLOPT_POSTFIELDS, $xml_data);
$reply = curl_exec($curll);
好吧不要问关于使用curl_errno($ch)
,curl_error($ch)
和curl_getinfo($ch)
,我已经使用过它们并得到了结果。
以下是成功进行localhost运行的结果和信息
Array ( [url] => http://emexonline.com:3000/MaximaWS/service.wsdl [content_type] => text/html [http_code] => 405 [header_size] => 203 [request_size] => 834 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.578 [namelookup_time] => 0.25 [connect_time] => 0.422 [pretransfer_time] => 0.422 [size_upload] => 617 [size_download] => 1293 [speed_download] => 2237 [speed_upload] => 1067 [download_content_length] => 1293 [upload_content_length] => 617 [starttransfer_time] => 0.578 [redirect_time] => 0 [redirect_url] => [primary_ip] => 86.98.88.87 [certinfo] => Array ( ) [primary_port] => 3000 [local_ip] => 192.168.0.102 [local_port] => 53325 )
error: no error
以下是服务器运行失败的结果和信息
Array ( [url] => http://emexonline.com/MaximaWS/Service.asmx [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 30.001115 [namelookup_time] => 0.12449 [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 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 )
error: Connection timed out after 30001 milliseconds
答案 0 :(得分:0)
你的代码还没有设置,你是否可以将超时从30增加到60 curl_setopt($ ch,CURLOPT_POST,1)此参数。