无法打开流:HTTP请求失败! HTTP / 1.0 503服务不可用

时间:2014-04-29 09:20:16

标签: php

我以root用户身份连接到我的服务器我有一个简单的php脚本:

<?php
$url ="http://www.ec.europa.eu/taxation_customs/vies/checkVatService.wsdl";
fopen($url, 'r');
?>

运行此php5 script.php后,我收到此错误:

PHP Warning:  fopen(http://www.ec.europa.eu/taxation_customs/vies/checkVatService.wsdl): 
failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable

请注意,当我尝试另一个url exp:http://google.com时,脚本不显示任何警告或错误,当我在浏览器中键入所需的URL时,它也能正常工作。 我检查了我的php.ini,变量allow_url_fopen已经设置为On。 从另一台服务器我尝试了相同的脚本(相同的URL),它的工作原理,所以问题与我的服务器没有所需的服务有关。 知道怎么避免这个吗?

编辑:

$ url =“http://www.ec.europa.eu/taxation_customs/vies/checkVatService.wsdl”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);

$result = curl_exec($ch);
var_dump($result);

给出:

* About to connect() to ec.europa.eu port 80 (#0)
*   Trying 2001:bc8:3408:200::2... * connected
> GET /taxation_customs/vies/checkVatService.wsdl HTTP/1.1
Host: ec.europa.eu
Accept: */*

* HTTP 1.0, assume close after body
< HTTP/1.0 503 Service Unavailable
< Cache-Control: no-cache
< Connection: close
< Content-Type: text/html
< Content-Length: 310
< 
* Excess found in a non pipelined read: excess = 20, size = 310, maxdownload = 310, bytecount = 0
* Closing connection #0
string(310) "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Error</title>
</head>
<body>
<h1>Erreur 503</h1>
<h2>Erreur proxy ipv6</"

1 个答案:

答案 0 :(得分:1)

使用简单的卷曲请求

$url = "http://www.ec.europa.eu/taxation_customs/vies/checkVatService.wsdl";

$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);

$result = curl_exec($ch);
var_dump($result);

返回“拒绝访问您的请求因安全原因而被拒绝”,您确定自己没有阻止请求吗?