简体   繁体   English

FedEx Rate Service上的PHP SOAP“获取HTTP正文……或分块数据时出错”

[英]PHP SOAP “Error Fetching http body … or chunked data” On FedEx Rate Service

I am getting "Error Fetching http body, No Content-Length, connection closed or chunked data" when doing a SOAP request to the Fedex Rate service. 对Fedex Rate服务执行SOAP请求时,出现“获取HTTP正文时出错,没有内容长度,连接关闭或分块的数据”。

Running Apache 2.4.4, PHP 5.4.12. 运行Apache 2.4.4,PHP 5.4.12。 This code is working on a different server, which is running Apache 2.2.3, PHP 5.3.27. 此代码在运行Apache 2.2.3,PHP 5.3.27的其他服务器上运行。

Here is my PHP code: 这是我的PHP代码:

require_once('fedex-common.php5');
$path_to_wsdl = __DIR__ . "/RateService_v10.wsdl";
ini_set( "soap.wsdl_cache_enabled", "0" );

$context = stream_context_create(array(
    'http'=>array(
        'protocol_version' => 1.0
    )
));

$client = new SoapClient( $path_to_wsdl, array( 'trace' => 1,  'stream_context'=>$context ) ); 

...

try {
    ...
    $response = $client->getRates( $request );
    ...
} catch ( SoapFault $exception ) {
    echo($client->__getLastRequestHeaders());
    echo($client->__getLastResponseHeaders());
    printFault( $exception, $client );
}

Running the code gives the following headers in the catch block - Request: 运行代码会在catch块中提供以下标头-请求:

POST /web-services/rate HTTP/1.1
Host: ws.fedex.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.12
Content-Type: text/xml; charset=utf-8
SOAPAction: "getRates"
Content-Length: 3875

Response: 响应:

HTTP/1.1 200 OK
Date: Thu, 31 Oct 2013 19:12:23 GMT
Server: Apache/2.2
x-wily-servlet: Encrypt1 GaMcoOotgOSMyoYj73M4dqm654IQUUy2VYo7kRLnWqp7O1G9YaZThSMVcxtIAA7cQSSESAO/CtqxI1OyaPemJzOZK7N+WNRwu686y5jWfxAuKqFeRiYJ1NPQTJShYPzp7gOpypOE/sg3Ti/CjdT3XaNt6/pEd18+pXDMyIfKrxnz4xWyAOl9y4Rosae418ks0PYNS9GJy2iOfaSXRiWFkA==
X-Powered-By: Servlet/2.5 JSP/2.1
x-wily-info: Clear guid=0FEE460DCC8738E20EC18F87798CDA26
Vary: Accept-Encoding
Keep-Alive: timeout=8, max=1024
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8

I am confused that the request is being made with HTTP/1.1 when I specify HTTP/1.0 (per recommendations on other questions). 我感到困惑的是,当我指定HTTP / 1.0时(使用其他问题的建议),请求是使用HTTP / 1.1发出的。 Also in the response header, it's definitely returning chunked data, causing that error. 同样在响应头中,它肯定会返回分块数据,从而导致该错误。 When I run the request myself in Advanced REST client (chrome extension), it works correctly, but also includes the Transfer-Encoding: chunked header that I believe is causing the problem. 当我自己在Advanced REST客户端(chrome扩展程序)中运行请求时,它可以正常运行,但还包含我认为引起问题的Transfer-Encoding: chunked块头。

I suspect there is some kind of issue with my Apache or PHP configuration. 我怀疑Apache或PHP配置存在某种问题。

Solution: Downgrading to Apache 2.2.22 and PHP 5.3.13 fixed the issue 解决方案:降级到Apache 2.2.22和PHP 5.3.13解决了该问题

降级到Apache 2.2.22和PHP 5.3.13解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM