php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42144 SoapServer returns invalid XML (first character is blank)
Submitted: 2007-07-30 14:11 UTC Modified: 2007-08-02 06:46 UTC
From: leubner at tablazzo dot com Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5.2.3 OS: WinXP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: leubner at tablazzo dot com
New email:
PHP Version: OS:

 

 [2007-07-30 14:11 UTC] leubner at tablazzo dot com
Description:
------------
I'm trying to implement a webservice with SoapServer and a WSDL description. The execution on the server works fine, parameters are passed and used correctly. However, the returned answer by SoapServer begin with a cr/lf/blank in front of "<?xml..." leading to a "looks like we got no XML document" when called by SoapClient (by the way it's the same when I call it from a VC++/ATL client, so SoapClient seems to have no problem at all). I traced the network traffic and found the CR/LF/blank (ASCII 32) as first character in the HTTP-body. 

Reproduce code:
---------------
// SoapServer:
// function get_aktie_detail is defined
	$server = new SoapServer("soap.wsdl");     
	$server->addFunction('get_aktie_detail'); 
	ini_set("soap.wsdl_cache_enabled", "0");
	$data = $HTTP_RAW_POST_DATA;
	$server->handle($data);       
// server-side execution works fine!


// SoapClient:
		$client = new SoapClient("http://192.168.1.200/joomla/components/com_parse/soap.wsdl");
		$id = 33;
		$objectresult = $client->get_aktie_detail($id);
     

// WSDL:
<?xml version='1.0' encoding='UTF-8'?>

<!-- WSDL file generated by Zend Studio. -->

<definitions name="frognetService" targetNamespace="urn:frognetService" xmlns:typens="urn:frognetService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
	<message name="get_aktie_detail">
		<part name="id" type="xsd:int"/>
	</message>
	<message name="get_aktie_detailResponse">
		<part name="get_aktie_detailReturn" type="xsd:int"/>
	</message>
	<portType name="HTMLPageServicePortType">
		<operation name="get_aktie_detail">
			<input message="typens:get_aktie_detail"/>
			<output message="typens:get_aktie_detailResponse"/>
		</operation>
	</portType>
	<binding name="HTMLPageServiceBinding" type="typens:HTMLPageServicePortType">
		<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
		<operation name="get_aktie_detail">
			<soap:operation soapAction="urn:HTMLPageServiceAction"/>
			<input>
				<soap:body namespace="urn:frognetService" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
			</input>
			<output>
				<soap:body namespace="urn:frognetService" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
			</output>
		</operation>
	</binding>
	<service name="frognetServiceService">
		<port name="HTMLPageServicePort" binding="typens:HTMLPageServiceBinding">
			<soap:address location="http://192.168.1.200/joomla/components/com_parse/soap.php"/>
		</port>
	</service>
</definitions>


Expected result:
----------------
As a result, $objectresult is expected to contain the return value of the webservice.

Actual result:
--------------
Result from this program:
		echo "SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring}";
		echo $client->__getLastResponse()."<hr>";
		echo $client->__getLastResponseHeaders()."<hr>";
		echo $client->__getLastRequest()."<hr>";
		echo $client->__getLastRequestHeaders()."<hr>";


SOAP Fault: (faultcode: Client, faultstring: looks like we got no XML document 1  HTTP/1.1 200 OK Date: Mon, 30 Jul 2007 13:49:33 GMT Server: Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.3 X-Powered-By: PHP/5.2.3 Content-Length: 559 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html 33 POST /joomla/components/com_parse/soap.php HTTP/1.1 Host: 192.168.1.200 Connection: Keep-Alive User-Agent: PHP-SOAP/5.1.6 Content-Type: text/xml; charset=utf-8 SOAPAction: "urn:HTMLPageServiceAction" Content-Length: 500

Result from Ethereal network sniffer:
HTTP-Traffic (please note the several 0D 0A and 20 in front of <?xml at 0110):
0000   00 ff 87 6d a5 ff 00 ff 88 6d a5 ff 08 00 45 00  ...m.....m....E.
0010   03 35 77 b9 40 00 80 06 b3 97 c0 a8 01 c8 0a 00  .5w.@...........
0020   00 02 00 50 05 29 d2 84 f1 58 9c b8 25 a1 50 18  ...P.)...X..%.P.
0030   42 7f 45 b9 00 00 48 54 54 50 2f 31 2e 31 20 32  B.E...HTTP/1.1 2
0040   30 30 20 4f 4b 0d 0a 44 61 74 65 3a 20 4d 6f 6e  00 OK..Date: Mon
0050   2c 20 33 30 20 4a 75 6c 20 32 30 30 37 20 31 32  , 30 Jul 2007 12
0060   3a 34 36 3a 31 33 20 47 4d 54 0d 0a 53 65 72 76  :46:13 GMT..Serv
0070   65 72 3a 20 41 70 61 63 68 65 2f 32 2e 32 2e 34  er: Apache/2.2.4
0080   20 28 57 69 6e 33 32 29 20 44 41 56 2f 32 20 6d   (Win32) DAV/2 m
0090   6f 64 5f 73 73 6c 2f 32 2e 32 2e 34 20 4f 70 65  od_ssl/2.2.4 Ope
00a0   6e 53 53 4c 2f 30 2e 39 2e 38 65 20 6d 6f 64 5f  nSSL/0.9.8e mod_
00b0   61 75 74 6f 69 6e 64 65 78 5f 63 6f 6c 6f 72 20  autoindex_color 
00c0   50 48 50 2f 35 2e 32 2e 33 0d 0a 58 2d 50 6f 77  PHP/5.2.3..X-Pow
00d0   65 72 65 64 2d 42 79 3a 20 50 48 50 2f 35 2e 32  ered-By: PHP/5.2
00e0   2e 33 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67  .3..Content-Leng
00f0   74 68 3a 20 35 35 39 0d 0a 43 6f 6e 74 65 6e 74  th: 559..Content
0100   2d 54 79 70 65 3a 20 74 65 78 74 2f 68 74 6d 6c  -Type: text/html
0110   0d 0a 0d 0a 0d 0a 20 3c 3f 78 6d 6c 20 76 65 72  ...... <?xml ver
0120   73 69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64  sion="1.0" encod
0130   69 6e 67 3d 22 55 54 46 2d 38 22 3f 3e 0a 3c 53  ing="UTF-8"?>.<S
0140   4f 41 50 2d 45 4e 56 3a 45 6e 76 65 6c 6f 70 65  OAP-ENV:Envelope
0150   20 78 6d 6c 6e 73 3a 53 4f 41 50 2d 45 4e 56 3d   xmlns:SOAP-ENV=
0160   22 68 74 74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e  "http://schemas.
0170   78 6d 6c 73 6f 61 70 2e 6f 72 67 2f 73 6f 61 70  xmlsoap.org/soap
0180   2f 65 6e 76 65 6c 6f 70 65 2f 22 20 78 6d 6c 6e  /envelope/" xmln
0190   73 3a 6e 73 31 3d 22 75 72 6e 3a 66 72 6f 67 6e  s:ns1="urn:frogn
01a0   65 74 53 65 72 76 69 63 65 22 20 78 6d 6c 6e 73  etService" xmlns
01b0   3a 78 73 64 3d 22 68 74 74 70 3a 2f 2f 77 77 77  :xsd="http://www
01c0   2e 77 33 2e 6f 72 67 2f 32 30 30 31 2f 58 4d 4c  .w3.org/2001/XML
01d0   53 63 68 65 6d 61 22 20 78 6d 6c 6e 73 3a 78 73  Schema" xmlns:xs
01e0   69 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 77 33  i="http://www.w3
01f0   2e 6f 72 67 2f 32 30 30 31 2f 58 4d 4c 53 63 68  .org/2001/XMLSch
0200   65 6d 61 2d 69 6e 73 74 61 6e 63 65 22 20 78 6d  ema-instance" xm
0210   6c 6e 73 3a 53 4f 41 50 2d 45 4e 43 3d 22 68 74  lns:SOAP-ENC="ht
0220   74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c  tp://schemas.xml
0230   73 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f 65 6e  soap.org/soap/en
0240   63 6f 64 69 6e 67 2f 22 20 53 4f 41 50 2d 45 4e  coding/" SOAP-EN
0250   56 3a 65 6e 63 6f 64 69 6e 67 53 74 79 6c 65 3d  V:encodingStyle=
0260   22 68 74 74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e  "http://schemas.
0270   78 6d 6c 73 6f 61 70 2e 6f 72 67 2f 73 6f 61 70  xmlsoap.org/soap
0280   2f 65 6e 63 6f 64 69 6e 67 2f 22 3e 3c 53 4f 41  /encoding/"><SOA
0290   50 2d 45 4e 56 3a 42 6f 64 79 3e 3c 6e 73 31 3a  P-ENV:Body><ns1:
02a0   67 65 74 5f 61 6b 74 69 65 5f 64 65 74 61 69 6c  get_aktie_detail
02b0   52 65 73 70 6f 6e 73 65 3e 3c 67 65 74 5f 61 6b  Response><get_ak
02c0   74 69 65 5f 64 65 74 61 69 6c 52 65 74 75 72 6e  tie_detailReturn
02d0   20 78 73 69 3a 74 79 70 65 3d 22 78 73 64 3a 69   xsi:type="xsd:i
02e0   6e 74 22 3e 31 3c 2f 67 65 74 5f 61 6b 74 69 65  nt">1</get_aktie
02f0   5f 64 65 74 61 69 6c 52 65 74 75 72 6e 3e 3c 2f  _detailReturn></
0300   6e 73 31 3a 67 65 74 5f 61 6b 74 69 65 5f 64 65  ns1:get_aktie_de
0310   74 61 69 6c 52 65 73 70 6f 6e 73 65 3e 3c 2f 53  tailResponse></S
0320   4f 41 50 2d 45 4e 56 3a 42 6f 64 79 3e 3c 2f 53  OAP-ENV:Body></S
0330   4f 41 50 2d 45 4e 56 3a 45 6e 76 65 6c 6f 70 65  OAP-ENV:Envelope
0340   3e 0a 20                                         >. 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-01 09:53 UTC] dmitry@php.net
You probably have <cr><lf> somewhere in you php script (or included file) before "<?php".
 [2007-08-02 06:46 UTC] leubner at tablazzo dot com
I apologize for having used the bug system. You gave the right hint: I've had CR/LF/blank at the end of an included script (behind "?>"), the part I normally don't care when creating HTML output. Thank you very much!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 15:01:29 2024 UTC