Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2005, 03:29 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default nusoap and require_once

Hi,

once I add a require_once('file.php') to my nusoap code my webservice doesn't work anymore.
ERROR:
Response not of type text/xml
RESPONSE
output started with file.php.

file.php can be either empty or like this one
<?php
$a='b';
?>

What's happening?

How can I fix the problem?
Thanks a lot.
Andrea

 
Old May 29th, 2005, 04:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Make sure that you don't have any extra whitespace in file.php. The PHP include functions (include, include_once, require, and require_once) all put the PHP parser back into text/html mode, not PHP mode.

It does this because all files, by default, are treated as plain text. The PHP parser re-enters PHP code mode when it sees the first code delimiter (e.g. <?php).


As such, if the PHP interpreter discovers ANY non-code text, it will spit out the default HTTP headers and send that non-code text to the client. More often than not, this non-code text is whitespace.

If you want to FORCE PHP to send the correct headers, you can:

a) Make sure to explicitly send the text/xml header before doing anything else, and/or
b) Trim ALL whitespace from all PHP source files.



Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with nuSoap snowbydave1 Pro PHP 1 August 26th, 2010 08:10 AM
Consuming Web service with NuSoap CraigWhitfield PHP How-To 0 February 27th, 2008 11:20 AM
Nusoap problem - empty request in web service ronenray PHP How-To 0 February 11th, 2007 12:43 PM
NuSoap WSDL help!!! kenson PHP How-To 0 November 23rd, 2006 02:03 AM
Help with require_once... mathe Beginning PHP 2 March 1st, 2004 09:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.