1

I try to use magento SOAP but i get the error "SoapFault exception: [HTTP] Unknown Content-Encoding"
the code i use is this:

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;
 }
}

when creating the object $proxy i get no errors, but when i call $sessionId = $proxy->login(...) i get the above exception.

The same code works fine for other magento installations.

Are there any suggestions?
Thanks..

2
  • Best guess, might be related with your server. Did you use apache deflate, header extensions? ( Or maybe you didn't use apache ) Commented Mar 16, 2012 at 14:47
  • i also believe it's server related, but i don't know where to look.. Commented Mar 16, 2012 at 15:36

3 Answers 3

1

Also, please try this and let share us result.

$proxy = new SoapClient($site_path.'api/soap/?wsdl=1');
Sign up to request clarification or add additional context in comments.

3 Comments

no this didn't help either.. don't know if this help but from eclipse debuger i get this response. $http_response_header Array [8] 0 (string:15) HTTP/1.1 200 OK 1 (string:35) Date: Fri, 16 Mar 2012 15:10:48 GMT 2 (string:14) Server: Apache 3 (string:22) Content-Encoding: none 4 (string:20) Content-Length: 9223 5 (string:16) Vary: User-Agent 6 (string:17) Connection: close 7 (string:37) Content-Type: text/xml; charset=UTF-8 ##sorry can't format inside comments..##
check apache mod_deflate, mod_header extensions. if they are enabled, temporarily disable and try again pls.
also, check php.ini output_handler = ob_gzhandler, if this line enabled, temporarily disable it. PS : if you are on shared hosting provider, you can set by .htaccess
0

Thanks a lot Oğuz. I'm struggling 2 days now and finaly found the solution. I don't know why the server responds like this (although i would really like to know) but if i create SoapClient with this, it works.

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

testing the code (without option 'compression' => SOAP_COMPRESSION_ACCEPT) on another server which uses gzip compression didn't have that problem..

Comments

0

Maybe this help somebody:

    $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 = new SoapClient ( $wsdl, $mode );

1 Comment

Can you elaborate on how this solves the issue? Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.