Hey guys,
I recently lost hours to the PHP 5.2.1 SoapClient when trying to use a remote webservice. There are two methods I have to use, the first one worked like a charm and the second one has me fuming mad. The two methods are "GetSessionToke n" which expects two strings, and "SetProjectData " which expects XML wrapped in a CDATA tag.
My problem is that the XML I pass to SetProjectData is being escaped by the PHP SoapClient and I don't know how to turn this off. The XML characters < > and & are being escaped to < > and & -- I need this to stop! It's not documented on php.net anywhere and I don't know where to turn.
Sample: -
$client = new SoapClient('my.wsdl',array('tracing'=>1));
-
-
$getSessionTokenParams = array('username'=>$username,'password'=>$password); //When passed to the webservice in the next line, this creates two XML tags, <username> and <password> with the appropriate values inside
-
-
$client->GetSessionToken($getSessionTokenParams); //Runs properly, gives me a session token.
-
-
$setProjectDataPayload = "<![CDATA[<data><projectinfo>details</projectinfo></data>]]>"; //Webservice expects inside XML to be wrapped in CDATA
-
-
$setProjectDataParam = array("sdsXML" => $setProjectDataPayload); //Webservice expects CDATA to be inside one sdsXML tag
-
-
//Here's where it breaks:
-
$client->SetProjectData($setProjectDataParam); //Remote webservice fails with "not properly formated XML" error
-
echo $client->__getLastRequest(); //Output the Webservice request and what do I find? $setProjectDataPayload has all of the XML tags <, > and & have all been escaped and I didn't do it. The sdsXML tag itself is not escaped, only its contents. Why is this happening? Where is this documented?
-
[Please use CODE tags when posting source code. Thanks! --pbmods]
Most importantly: How the heck do I turn "feature" off? I just want it to pass the literal data I send to it, please no chracter escaping!
4 14239
Hey guys,
I recently lost hours to the PHP 5.2.1 SoapClient when trying to use a remote webservice. There are two methods I have to use, the first one worked like a charm and the second one has me fuming mad. The two methods are "GetSessionToke n" which expects two strings, and "SetProjectData " which expects XML wrapped in a CDATA tag.
My problem is that the XML I pass to SetProjectData is being escaped by the PHP SoapClient and I don't know how to turn this off. The XML characters < > and & are being escaped to < > and & -- I need this to stop! It's not documented on php.net anywhere and I don't know where to turn.
Sample: -
$client = new SoapClient('my.wsdl',array('tracing'=>1));
-
-
$getSessionTokenParams = array('username'=>$username,'password'=>$password); //When passed to the webservice in the next line, this creates two XML tags, <username> and <password> with the appropriate values inside
-
-
$client->GetSessionToken($getSessionTokenParams); //Runs properly, gives me a session token.
-
-
$setProjectDataPayload = "<![CDATA[<data><projectinfo>details</projectinfo></data>]]>"; //Webservice expects inside XML to be wrapped in CDATA
-
-
$setProjectDataParam = array("sdsXML" => $setProjectDataPayload); //Webservice expects CDATA to be inside one sdsXML tag
-
-
//Here's where it breaks:
-
$client->SetProjectData($setProjectDataParam); //Remote webservice fails with "not properly formated XML" error
-
echo $client->__getLastRequest(); //Output the Webservice request and what do I find? $setProjectDataPayload has all of the XML tags <, > and & have all been escaped and I didn't do it. The sdsXML tag itself is not escaped, only its contents. Why is this happening? Where is this documented?
-
[Please use CODE tags when posting source code. Thanks! --pbmods]
Most importantly: How the heck do I turn "feature" off? I just want it to pass the literal data I send to it, please no chracter escaping!
I haven't used PHP's built in SOAP client so I can't help you with how to turn the escaping off.. however, if you remove the <![CDATA[ tags it would be equivalent to the actual CDATA wrapped in <![CDATA[.
It would work unless the soap server actually needs the <![CDATA[ tags?
The server expects the CDATA tags for one, and more importantly the XML I send inside of CDATA is being escaped anyways: Even if I remove the CDATA text, I still end up with <myxmltag> ; and the remote call fails.
I can't be the first person to use CDATA with PHP's SoapClient. I just can't figure out why in the world my data is being escaped.
Edit** In my original code, I pass:
in the SoapClient constructor but the proper value is actually
I just wrote a simple class to do it.
Signed up to help you out, so, I hope it does! -
class XMLClient extends SoapClient {
-
-
public function XMLClient($wsdl) {
-
try {
-
parent::__construct($wsdl);
-
} catch (SoapFault $exception) {
-
$this->error = $exception;
-
}
-
}
-
-
public function __doRequest($request, $location, $action, $version) {
-
$request = str_replace("<", "<", $request);
-
$request = str_replace(">", ">", $request);
-
print "Request - " . $request;
-
return parent::__doRequest($request, $location, $action, $version );
-
}
-
}
-
Usage: -
$x = XMLClient("my.wsdl");
-
$x->getSomeBooks("<some><xml><content></content></xml></some>");
-
I had the same problem. After some trail and error. If found a solution. You could use SoapVar with XSD_ANYXML. - new SoapVar("<param2><![CDATA[<html><body>Some content</body></html>]]> </param2>", XSD_ANYXML)
Blogged it over here: http://bit.ly/e8oPrt Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lisa |
last post by:
I need to apply the HTML formatting tags and the French accented
characters in a XML document. The XML is generated from a database
that has HTML tags and French accented characters in the records.
I have specified <xsl:output method="html"/> and
encoding="iso-8859-1".
When I apply the xsl:value-of and set the disable-output-escaping to
"yes", the HTML formatting tags are displayed correctly, but the
French accented characters are...
|
by: Jim Bancroft |
last post by:
Hi everyone,
I receive XML documents which sometimes have HTML in the element
content. When performing XSL transformations the HTML text is escaped,
which affects us when we eventually display it in a browser.
I understand there's a "disable-output-escaping" attribute that can be
used in <xsl:value-of> elements, but is there way to do the same thing
across the entire XML document, by default, without having to modify
individual XSL...
|
by: Robert Bowen |
last post by:
Hello peeplez. I have an odd problem. When I put the ANSI symbol for
"less than" ("<"), the word STRONG and then the ANSI symbol for
"greater than" (">") in my web page, followed by some text, then close
the STRONG tag the same way, my text appears in bold. No problem.
When I do the same things with the corresponding HTML tags (< ,
> ) the tag is not interpreted, it is simply displayed:
<STRONG>text</STRONG>
|
by: Kathleen Dollard |
last post by:
Hi,
Oleg's answer about attribute value templates led me to look back at a
different problem, and wonder if someone else had solved it.
I want to output an ASP.NET page. Thus I need to output ASP.NET tags and
HTML tags.
<%@ Page Language= etc...
|
by: Yolande |
last post by:
Hi there,
I try to use MSSOAPLib.soapClient to get the XML data produced by our web
services. I have a web method call ReportExec(strID, strRequest). It takes
two string arguments and returns a Xml.XmlNode object. When I test the web
services using IE, I receive the XML data I want. But when I use
MSSOAPLib.soapClient in MS Access, I got an error of “Wrong number of
arguments or invalid property assignment.” I don't think this was...
| |
by: Andy |
last post by:
Hi, I'm trying to render tabular data in an HTML document using XSL to
transform XML data into an HTML table. Some of the tabular data
appears as droplists (implemented by the HTML Select and Option tags).
All the droplists have the same option entries that a user can choose
from.
Is there anyway to reuse a single "master" branch in the XML document
that contains all the option entries for all the select droplists in
the XSL document?...
|
by: macupryk |
last post by:
soapclient. need to extract information in php from a webservice that was built in C# asp.net 2.0
I am new to php. Can someone help me with the code below.
I would like to learn how to manipulate the information so if the user would like to display
the contents of start_date on his/her web page. How would I go parsing this.
<?xml version="1.0" encoding="utf-8" ?>
- <Program xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
|
by: brandonkirsch |
last post by:
Hey guys, I've posted a question on here before but I don't think I was very direct about the problem so I'll state it in a new way:
How do I send CDATA to a webservice using the PHP SoapClient?
Currently I am creating a $string full of CDATA and XML tags. But when I pass this to the webservice, the CDATA and XML tags are escaped and lose their meaning.
$client = new SoapClient("my.wsdl",array("trace"=>1));
$string = "<! ]>";...
|
by: jamieg99 |
last post by:
Hello,
I've got an object that's being converted into SAXSource and then converted into a pdf with FOP. Some of the data however is in HTML format inside the xml tags and is being escaped (>, etc) before it transformed.
I'd like to have this these html tags parsed as actual elements by the stylesheet, which would mean reading it in it's unescaped format, but I can't figure out how to do this. I have "disable-output-escaping" set in the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |