[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I send CDATA with php/nusoap?

Posted on 2011-02-21
3
Medium Priority
?
2,736 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

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

649 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