PHP Soap problem - "looks like we got no XML document" Any help would be lovely!
Results 1 to 14 of 14

Thread: PHP Soap problem - "looks like we got no XML document" Any help would be lovely!

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    1

    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:

    ------=_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--


    Which looks ok and has the value in I need, but my PHP is throwing an exception on this saying "[message : protected] => looks like we got no XML document" 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

  2. #2
    Junior Member
    Join Date
    Apr 2009
    Posts
    1

    Workaround

    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.

  3. #3
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,889
    Quote Originally Posted by brummie
    Which looks ok
    I have to say it doesn't look OK to me.
    Code:
    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?
    Last edited by Weedpacket; 04-03-2009 at 06:14 AM.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  4. #4
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    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!

  5. #5
    Senior Member
    Join Date
    Jul 2007
    Posts
    3,658
    If they have an error with their service, there is nothing you can do to fix it. File a bug report.

  6. #6
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,887
    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.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  7. #7
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Quote Originally Posted by sneakyimp View Post
    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.

    PHP 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());
                
            } 
    I look forward to your help and support.

    Cheers
    Last edited by bradgrafelman; 01-27-2014 at 04:19 PM. Reason: bbcode tags added

  8. #8
    Senior Member
    Join Date
    Jul 2007
    Posts
    3,658
    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?

  9. #9
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,887
    Your code has a syntax error -- meaning it won't even run at all.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  10. #10
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,716
    Quote Originally Posted by dc2014 View Post
    written in object oriented manner
    Those `MSWord' objects don't work in very many languages at all, actually
    Last edited by dalecosp; 01-28-2014 at 02:49 PM.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  11. #11
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    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.

    3. 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());

    }

  12. #12
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    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


    Quote Originally Posted by dc2014 View Post
    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.

    3. 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());

    }

  13. #13
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,887
    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?
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  14. #14
    Junior Member
    Join Date
    Jan 2014
    Posts
    5

    Reply

    Quote Originally Posted by sneakyimp View Post
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •