• PHP Help General Help
  • PHP Soap problem - "looks like we got no XML document" Any help would be lovely!

Hi,

I'm a bit new to using web services with PHP and I've hit this problem. When I do getlastrequest on my call I get this output:

[FONT="Courier New"]------=_Part_23_26643509.1224148811737
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID:

8
------=_Part_23_26643509.1224148811737--[/FONT]

Which looks ok and has the value in I need, but my PHP is throwing an exception on this saying [FONT="Courier New"]"[message : protected] => looks like we got no XML document"[/FONT] so I can't access this value etc.

Has any one any hints on what is wrong here? It's driving me crazy. Is it that the XML the webservice is chucking back is wrong? Or that PHP just can't deal with a repsonse like this?

Is there anyway around this? I can't change the webservice, it's someone elses, but I need to be able to access the values without the script failing.

Please help if you can.

Thanks

    6 months later

    It may be that you're actually receiving the correct XML from the server, but the SoapClient is still throwing this exception for some reason. This is what happened to me. Someone on the php.net site posted a workaround for this. Include these entries in the array of options passed to the constructor:
    "trace" => 1, "exceptions" => 0

    This will stop it from throwing the exception and enable the SoapClient's __getLastResponse() function, which should return the actual response you got from the server.

      brummie wrote:

      Which looks ok

      I have to say it doesn't look OK to me.

      8

      is not a well-formed XML document. Is that a misplaced Content-ID - in which case there doesn't seem to be any content at all?

        5 years later

        hi all, we are also having a similar issue:

        soap 1.1. magneto 1.7.0.2

        We developed an app that pushes and retrieves data from one program to Magento via the Magento API via SOAP.

        This is the kind of post would we send to the magento store:

        Example:
        [08/Oct/2013:16:49:59 -0400] "POST /index.php/api/soap/index/ HTTP/1.0" 200 266 "-" "-"

        Basically when we attempt to send these commands to the Magneto site / Server
        it stops and we receive the following error:

        MAGENTO::ERROR: looks like we got no XML document"

        During the connection, the actual return from their magento web service is as follows:

        Warning: include() [function.include]: Failed opening '/home/sistaco5/public_html/includes/src/Jemoon_Htmlminify_Model_Observer.php' for inclusion (include_path='/home/sistaco5/public_html/includes/src:.:/usr/local/php53/pear') in /home/sistaco5/public_html/includes/src/Varien_Autoload.php on line 93

        This does not look like an XML.

        I believe the error may be related to BOM I found at the following article:

        http://www.highonphp.com/fixing-soap-exception-no-xml

        Not sure if this above article will work, but any other thoughts on how to address the above would be very much appreciated.

        Look forward to your help and support guys / gals!

          If they have an error with their service, there is nothing you can do to fix it. File a bug report.

            You have mentioned PHP code and complained about an error, but haven't showed anybody the PHP code you are using. That makes a diagnosis very difficult.

              7 days later
              sneakyimp;11037441 wrote:

              You have mentioned PHP code and complained about an error, but haven't showed anybody the PHP code you are using. That makes a diagnosis very difficult.

              HI there, thanks for the reply and apologies for the delay.

              Not sure which snippet to provide you since our app is written in object oriented manner. probably you can send the following below. this is just an extract.

              		ini_set('max_execution_time', 300); 
              
              	$opt = array('trace'=>1,'encoding'=>'utf-8', 'exceptions' => 0);
              	$client = new SoapClient('http://magentosite.com/api/soap/?wsdl’, $opt);
              	$session = $client->login(‘user', ‘pass');
              
              	try 
              	{
              		$result = $client->call($session, 'sales_order.info', '1200000142');
              		echo "<pre>";
              		var_dump($result);
              		echo "</pre>";
              	}
              	catch (exception $e)
              	{
              		var_dump($e->getMessage());
              
              		var_dump($client->__getLastRequest());
              		var_dump($client->__getLastResponse());
              
              	}

              I look forward to your help and support.

              Cheers

                1. What errors do you get?
                2. Are you aware of the differences between ' and `?
                3. Can you spot anything weird with help of the syntax highlighting in the code of your previous post?

                  Your code has a syntax error -- meaning it won't even run at all.

                    dc2014;11037801 wrote:

                    written in object oriented manner

                    Those [SUB]`[/SUB]MSWord' objects don't work in very many languages at all, actually 😉

                      This code of course that i provided had a formatting issue.

                      Answers:
                      1. What errors do you get?
                      2. Are you aware of the differences between ' and `?

                      This is actually the wrong one, single quote & tick quote from which was auto-formatted by the email client i use because of the explanation above.

                      1. Can you spot anything weird with help of the syntax highlighting in the code of your previous post?

                      n/a for my email client formatted the code.

                      please see the corrected code:

                      ini_set('max_execution_time', 300);

                      $opt = array('trace'=>1,'encoding'=>'utf-8', 'exceptions' => 0);
                      $client = new SoapClient('http://magentosite.com/api/soap/?wsdl', $opt);
                      $session = $client->login('user', 'pass');

                      try
                      {
                      $result = $client->call($session, 'sales_order.info', '1200000142');
                      echo "<pre>";
                      var_dump($result);
                      echo "</pre>";
                      }
                      catch (exception $e)
                      {
                      var_dump($e->getMessage());

                      var_dump($client->__getLastRequest());
                      var_dump($client->__getLastResponse());

                      }

                        We are no longer getting the error "looks like we got no XML document" anymore, we are now getting a new error:

                        "transfer closed with 1 bytes remaining to read"

                        So keen to hear your thoughts on my correct code and now the new error.

                        Look forward to your help all.

                        THanks

                        dc2014;11037989 wrote:

                        This code of course that i provided had a formatting issue.

                        Answers:
                        1. What errors do you get?
                        2. Are you aware of the differences between ' and `?

                        This is actually the wrong one, single quote & tick quote from which was auto-formatted by the email client i use because of the explanation above.

                        1. Can you spot anything weird with help of the syntax highlighting in the code of your previous post?

                        n/a for my email client formatted the code.

                        please see the corrected code:

                        ini_set('max_execution_time', 300);

                        $opt = array('trace'=>1,'encoding'=>'utf-8', 'exceptions' => 0);
                        $client = new SoapClient('http://magentosite.com/api/soap/?wsdl', $opt);
                        $session = $client->login('user', 'pass');

                        try
                        {
                        $result = $client->call($session, 'sales_order.info', '1200000142');
                        echo "<pre>";
                        var_dump($result);
                        echo "</pre>";
                        }
                        catch (exception $e)
                        {
                        var_dump($e->getMessage());

                        var_dump($client->__getLastRequest());
                        var_dump($client->__getLastResponse());

                        }

                          Sounds to me like the remote website (hosting the soap app) sent a content-length header that said you should expect to receive N bytes but then sent N-1 bytes and disconnected your client. This could be a minor problem with the SOAP server, or perhaps you might set an option in your SOAP call to ignore certain errors?

                            a month later
                            sneakyimp;11038073 wrote:

                            Sounds to me like the remote website (hosting the soap app) sent a content-length header that said you should expect to receive N bytes but then sent N-1 bytes and disconnected your client. This could be a minor problem with the SOAP server, or perhaps you might set an option in your SOAP call to ignore certain errors?

                            Hi Sneakyimp, thanks so much for your input, and apologies for the delay in actually responding, I really appreciate your efforts and everyones efforts on this forum, you all rock!

                            Anyways, how would you do it if you are using php CURL to access magento api?

                            I cant find anything online, after countless of forums etc.

                            I look forward to your help and support 🙂.

                            Thanks

                              Write a Reply...