magento肥皂;未知内容编码“;

magento肥皂;未知内容编码“;,magento,soap,Magento,Soap,我尝试使用magento SOAP,但出现错误“SoapFault异常:[HTTP]未知内容编码” 我使用的代码如下: function init_connector() { global $mage_url,$mage_user, $mage_api_key, $sessionId, $proxy; try { $proxy = new SoapClient( $mage_url ."/api/?wsdl" ); //calling this function with no error

我尝试使用magento SOAP,但出现错误“SoapFault异常:[HTTP]未知内容编码”
我使用的代码如下:

function init_connector() {
global $mage_url,$mage_user, $mage_api_key, $sessionId, $proxy;

try {

 $proxy = new SoapClient( $mage_url ."/api/?wsdl" ); //calling this function with no errors
 // Login to Magento
 $sessionId = $proxy->login( $mage_user, $mage_api_key ); //this call trigers the exception
 return 1;
 } catch( SoapFault $fault ) {
    logError($fault);
    return 0;
 }
}
当创建对象$proxy时,我没有得到任何错误,但是当我调用$sessionId=$proxy->login(…)时,我得到了上面的异常

同样的代码也适用于其他magento安装

有什么建议吗?

谢谢。

另外,请尝试一下,并让我们分享结果

$proxy = new SoapClient($site_path.'api/soap/?wsdl=1');

另外,请尝试这个,让我们分享结果

$proxy = new SoapClient($site_path.'api/soap/?wsdl=1');
多谢奥乌兹。 我挣扎了两天终于找到了解决办法。我不知道为什么服务器会做出这样的响应(尽管我真的很想知道),但是如果我用这个创建SoapClient,它就会工作

$proxy = new SoapClient( $mage_url, array('compression' => SOAP_COMPRESSION_ACCEPT));
在另一台使用gzip压缩的服务器上测试代码(没有选项“压缩”=>SOAP_compression_ACCEPT)没有这个问题。

非常感谢奥乌兹。 我挣扎了两天终于找到了解决办法。我不知道为什么服务器会做出这样的响应(尽管我真的很想知道),但是如果我用这个创建SoapClient,它就会工作

$proxy = new SoapClient( $mage_url, array('compression' => SOAP_COMPRESSION_ACCEPT));

在另一台使用gzip压缩的服务器上测试代码(不带选项“压缩”=>SOAP\u compression\u ACCEPT)没有这个问题。

这可能会帮助某些人:

    $mode = array (
        'soap_version'  => 'SOAP_1_1', // use soap 1.1 client
        'keep_alive'    => true,
        'trace'         => 1,
        'encoding'      =>'UTF-8',
        'compression'   => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
        'exceptions'    => true,
        'cache_wsdl'    => WSDL_CACHE_NONE,
        'stream_context' => stream_context_create ( 
            array (
                'http' => array('header' => 'Content-Encoding: gzip'),
            )
        )
    ); 

$client=newsoapclient($wsdl,$mode)

也许这对某人有帮助:

    $mode = array (
        'soap_version'  => 'SOAP_1_1', // use soap 1.1 client
        'keep_alive'    => true,
        'trace'         => 1,
        'encoding'      =>'UTF-8',
        'compression'   => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
        'exceptions'    => true,
        'cache_wsdl'    => WSDL_CACHE_NONE,
        'stream_context' => stream_context_create ( 
            array (
                'http' => array('header' => 'Content-Encoding: gzip'),
            )
        )
    ); 

$client=newsoapclient($wsdl,$mode)

最佳猜测,可能与您的服务器有关。您是否使用了ApacheDeflate头扩展?(或者可能你没有使用apache)我也相信它与服务器有关,但我不知道该去哪里找。最好的猜测是,可能与你的服务器有关。您是否使用了ApacheDeflate头扩展?(或者你可能没有使用apache)我也相信它与服务器相关,但我不知道该去哪里找..不,这也没用。。不知道这是否有帮助,但从eclipse调试程序我得到了这个响应$http_response_header Array[8]0(string:15)http/1.1200 OK 1(string:35)日期:Fri,2012年3月16日15:10:48 GMT 2(string:14)服务器:Apache 3(string:22)内容编码:无4(string:20)内容长度:9223 5(string:16)变化:用户代理6(string:17)连接:关闭7(string:37)内容类型:text/xml;charset=UTF-8###抱歉,无法格式化内部注释..##检查apache mod#u deflate、mod#u头扩展。如果它们已启用,请暂时禁用并重试。另外,请检查php.ini
output\u handler=ob\u gzhandler
,如果此行已启用,请暂时禁用它。PS:如果您是共享主机提供商,您可以通过
设置.htaccess
否这也没有帮助。。不知道这是否有帮助,但从eclipse调试程序我得到了这个响应$http_response_header Array[8]0(string:15)http/1.1200 OK 1(string:35)日期:Fri,2012年3月16日15:10:48 GMT 2(string:14)服务器:Apache 3(string:22)内容编码:无4(string:20)内容长度:9223 5(string:16)变化:用户代理6(string:17)连接:关闭7(string:37)内容类型:text/xml;charset=UTF-8###抱歉,无法格式化内部注释..##检查apache mod#u deflate、mod#u头扩展。如果它们已启用,请暂时禁用并重试。另外,请检查php.ini
output\u handler=ob\u gzhandler
,如果此行已启用,请暂时禁用它。PS:如果您是共享主机提供商,您可以通过
设置。htaccess
您能否详细说明如何解决此问题?谢谢。你能详细说明一下这是如何解决这个问题的吗?谢谢