?
Solved

How do I send CDATA with php/nusoap?

Posted on 2011-02-21
3
Medium Priority
?
2,682 Views
Last Modified: 2012-05-11
Hello,
I've had great success in using nusoap to make calls to another server and parse results... until I tried sending CDATA. It converted all the XML data in my parameter string into entities (see file attached).

Here's a simplified version of what I have. Any thoughts on how to prevent nusoap from messing with my request? :)

<?php
include_once 'nusoap-0.9.5/lib/nusoap.php';
	
$functionName = 'Say';
$request['Text'] = array(
	'SynthString' => '<![CDATA[I am <prosody rate="x-slow">very happy</prosody>]]>',
	'Encoding' => 'UTF-8'
);
$request['VoiceInfo'] = array(
	'Name' => 'Princess',
	'Owner' => 'Cepstral'
);
$request['AudioInfo'] = array(
	'SignalRate' => '16',
	'Format' => 'mp3',
	'DeliveryType' => 'link'
);

$soapClient = new nusoap_client('http://' . 'theserver.com', false);
$result = $soapClient->call($functionName, $request);

//write request to file as seen as an attachment for this post
$myFile = "request.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $soapClient->request;
fwrite($fh, $stringData);
fclose($fh);
?>

Open in new window


Thanks much for the assist in advance! :D
request.xml
0
Comment
Question by:Ultrus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Author Comment

by:Ultrus
ID: 34946115
OK, I found the magic variable in the nusoap_base class in nusoap.php:

        /**
	 * toggles automatic encoding of special characters as entities
	 * (should always be true, I think)
	 *
	 * @var boolean
	 * @access private
	 */
	var $charencoding = true;

Open in new window


Setting it to false makes my calls work again. Yay! 50% there.

Now, how do I set this without changing the base class file? Since it's a private variable, the following causes an error:
$soapClient = new nusoap_client('http://' . 'theserver.com', false);
$soapClient->$charencoding = false;

Open in new window


:/
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 2000 total points
ID: 34957063
I have not done this myself, but you might try -

$soapclient->charencoding = false;

In Object Oriented coding, you do NOT place a second  $  as you did
0
 
LVL 10

Author Closing Comment

by:Ultrus
ID: 34957142
Oh! What a silly mistake I made. It works for me now. Cheers to you for helping me solve the simple things that matter. :)
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question