Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6994021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:50:19+00:00 2026-05-27T19:50:19+00:00

I tested Magento’s SOAP API using soapUI. I successfully logged in and got a

  • 0

I tested Magento’s SOAP API using soapUI. I successfully logged in and got a login hash.
Then I tried to retrieve a list of products and this worked fine.

This was on a Linux server using the latest version of Apache, mySQL and PHP.

I then created a backup of Magento and the database. I wanted to create a test environment on a Lion server using a MAMP stack. The Magento backup seems to work fine, but the SOAP API doesn’t.

Again I used soapUI to get a login hash and tried to retrieve all products. But now the response seems to be incomplete:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento">
<SOAP-ENV:Body>
<ns1:catalogProductListResponseParam>
<result>
<complexObjectArray>
<product_id>7167</product_id>
<sku>000140</sku>
... etc ...
<complexObjectArray>34</complexObjectArray>
</category_ids>
<website_ids>
<complexObjectArray>1</complexObjectArray>
</website_ids>
</complexObjectArray>
<complexObjectArray>
<product

Why is the reponse incomplete under Lion/MAMP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:50:19+00:00Added an answer on May 27, 2026 at 7:50 pm

    I had a problem with incomplete SOAP XML responses once.

    The setup was like this:

    • Linux server
    • Magento CE 1.5.1.0
    • Usage of SOAP v2 with WS-I compliance enabled
    • Call of sales_order.info

    Even if you use a different Magento version and a different SOAP call, you may suffer from a similar bug as I did. The problem was that the HTTP Content-Length header was calculated incorrectly for responses > 8000 bytes.

    How to verify if you are affected by this bug:

    1. Execute a call which delivers a short response (e.g. “catalog_category.info” with just a single store-view and only few attributes). If the XML is complete, check if the response has a length <= 8000 bytes.
    2. Copy the file app/code/core/Mage/Api/Model/Server/Wsi/Adapter/Soap.php to your app/code/local folder and edit the run() method. If you use the “wsdl” parameter in your SOAP URL, edit the first part of the “if” structure, otherwise edit the “else” part.

    As the second way is the more accurate way to do it, I’ll go with this.

    1. Open the file and search for the ->setBody() method call. As you can see, there is some search/replace magic going on.
    2. Write the result of the search/replace operations into a variable and log it for further examination. The code may look like this:

      public function run()
      {
          $apiConfigCharset = Mage::getStoreConfig("api/config/charset");
      
          if ($this->getController()->getRequest()->getParam('wsdl') !== null) {
              /* don't modify the first part ... */
          } else {
              try {
                  $this->_instantiateServer();
      
                  $content = preg_replace(
                          '/(\>\<)/i',
                          ">\n<",
                          str_replace(
                                  '<soap:operation soapAction=""></soap:operation>',
                                  "<soap:operation soapAction=\"\" />\n",
                                  str_replace(
                                          '<soap:body use="literal"></soap:body>',
                                          "<soap:body use=\"literal\" />\n",
                                          preg_replace(
                                              '/<\?xml version="([^\"]+)"([^\>]+)>/i',
                                              '<?xml version="$1" encoding="'.$apiConfigCharset.'"?>',
                                              $this->_soap->handle()
                                          )
                                  )
                          )
                  );
                  Mage::log($content, null, 'soap.log');
                  $this->getController()->getResponse()
                       ->clearHeaders()
                       ->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset)
                       ->setBody($content);
              } catch( Zend_Soap_Server_Exception $e ) {
                  $this->fault( $e->getCode(), $e->getMessage() );
              } catch( Exception $e ) {
                  $this->fault( $e->getCode(), $e->getMessage() );
              }
          }
      }
      
    3. Execute the SOAP API call and open var/log/soap.log in your Magento directory. If the XML is complete in the log file but not in your response, then the Content-Length header is the problem.

    How to correct the Content-Length header

    1. Stay in your copy of Mage_Api_Model_Server_Wsi_Adapter_Soap and add one line to the code we just modified:

      public function run()
      {
          $apiConfigCharset = Mage::getStoreConfig("api/config/charset");
      
          if ($this->getController()->getRequest()->getParam('wsdl') !== null) {
              /* don't modify the first part ... */
          } else {
              try {
                  $this->_instantiateServer();
      
                  $content = preg_replace(
                          '/(\>\<)/i',
                          ">\n<",
                          str_replace(
                                  '<soap:operation soapAction=""></soap:operation>',
                                  "<soap:operation soapAction=\"\" />\n",
                                  str_replace(
                                          '<soap:body use="literal"></soap:body>',
                                          "<soap:body use=\"literal\" />\n",
                                          preg_replace(
                                              '/<\?xml version="([^\"]+)"([^\>]+)>/i',
                                              '<?xml version="$1" encoding="'.$apiConfigCharset.'"?>',
                                              $this->_soap->handle()
                                          )
                                  )
                          )
                  );
                  Mage::log($content, null, 'soap.log');
                  $this->getController()->getResponse()
                       ->clearHeaders()
                       ->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset)
                       ->setHeader('Content-Length',strlen($content), true)
                       ->setBody($content);
              } catch( Zend_Soap_Server_Exception $e ) {
                  $this->fault( $e->getCode(), $e->getMessage() );
              } catch( Exception $e ) {
                  $this->fault( $e->getCode(), $e->getMessage() );
              }
          }
      }
      

      Note the line:

      ->setHeader('Content-Length',strlen($content), true)
      

      We calculate and set the Content-Length header. The third parameter, true, is important because it tells the framework to overwrite the existing Content-Length header.

    2. If this works, remove the Mage::log() call and rewrite the code for use in your own extension.

    If you ask why this problem occurs I can’t tell you exactly because I didn’t hunt the bug all the way down.

    From what I saw, everything is fine as long as the XML response has a length <= 8000 bytes. If the response is longer than 8000 bytes and the XML consists of x lines, the response is truncated by x characters. It looks like it is a problem with the different carriage return codes and/or with encoding issues which lead to the wrong calculation of the response content length.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried and tested the JMX API and it is pretty simple to
I tested successfully with Linux by using Avahi(Bonjour) and Netatalk(AFP) to provide network storage
I have tested the below script on a demo page which is not using
I'm just learning git and its basic fundamentals. I've got a live Magento store
I tested calling a soap 12 webservices with ksoap2. I used this code to
I was using Magento 1.4.1 and upgrade gracefully to 1.4.2. After testing if the
I tested JDBM2 which is really a great API to persist data directly in
I tested my site with Chrome and got the following recommendation: The following resources
I tested with simple nant (0.90) on Mac OS X 10.6.4, but I got
I tested: rm \-\-remove-files but I am unable to remove it. How can I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.