SOAP: looks like we got no XML document

前端 未结 10 1288
日久生厌
日久生厌 2021-01-11 11:41

I\'m trying to create a web service but before I do I\'m trying to get a simple example that I found on the internet to work first but I keep getting the following error:

相关标签:
10条回答
  • 2021-01-11 11:54

    A byte order mark (BOM) would have the same effect as whitespace before the php tags. Here you find a PHP snippet to detect and remove a BOM. Be sure to configure you editor to not insert the BOM again.

    0 讨论(0)
  • 2021-01-11 11:54

    Another possible solution...

    I had the same problem, I was getting crazy. The solution was simple. Verifying my server.. cause it is a server error. My error was that i had put "rcp" instead of "rpc".

    0 讨论(0)
  • 2021-01-11 11:56

    This error appears also if a soap XML response contains special Unicode characters. In my case it was REPLACEMENT CHARACTER (U+FFFD).

    In details, inner function of the SoapClient xmlParseDocument sets xmlParserCtxtPtr->wellFormed property as false after parsing. It throws soap fault with looks like we got no XML document.

    https://github.com/php/php-src/blob/master/ext/soap/php_packet_soap.c#L46

    0 讨论(0)
  • 2021-01-11 11:59

    As far as I understand, the error of the SOAP parser when it comes invalid XML.

    As it was with me.

    1. Turn on the display of the error
    2. performed in try-catch and in the catch call __getLastResponse
    3. I catch another error:

    Warning: simplexml_load_string(): Entity: line 1: parser error : xmlParseCharRef: invalid xmlChar value 26 in

    1. The first patient was PHP5.3. Once run the script on the PHP5.4, became more informative error - I swear on an invalid character, because of which, presumably, and fell SOAP parser.

    As a result, I obtained the following code:

    $params = array(...);
    try
    {
        $response = $client->method( $params );
    }
    catch(SoapFault $e)
    {
        $response = $client->__getLastResponse();
        $response = str_replace("&#x1A",'',$response); ///My Invalid Symbol
        $response = str_ireplace(array('SOAP-ENV:','SOAP:'),'',$response);
        $response = simplexml_load_string($response);
    }
    

    If someone will tell in the comments what a symbol, I will be grateful.

    0 讨论(0)
  • 2021-01-11 12:01

    A bit late, but this kinda error is often caused by server-side (SOAP sense) problem :

    • print/echo content
    • rik's answer too
    • mistake (eg I was currently having this error because of a miswritten filename in an include, generating an include error instead of executing the script...)
    • bad parameter in SOAP server
    • not the same compression level both sides (if compression used)

    This message just inform you that the SOAP client did not receive well-formatted XML (eg. an error message instead of XML).

    0 讨论(0)
  • 2021-01-11 12:01

    Try to look into your server log. If you use nginx, please look into /var/log/nginx/error.log. if "Permission denied" pop up, please change related dir owner. Hope it will work.

    0 讨论(0)
提交回复
热议问题