Solved

How do I send CDATA with php/nusoap?

Posted on 2011-02-21
3
2,477 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
  • 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 33

Accepted Solution

by:
Slick812 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now