473,807 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing CDATA with SoapClient?

7 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. $client = new SoapClient("my.wsdl",array("trace"=>1));
  2. $string = "<! [CDATA[<myxml>]]>";
  3. $client->remoteMethod(array("tagname" => $string));
  4.  
When done this way, $string's tags are converted to &lt; and &gt; but "<tagname>" is proper -- how do I properly pass CDATA to a webservice using the PHP SoapClient?
Jun 13 '07 #1
11 21815
Motoma
3,237 Recognized Expert Specialist
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.

Expand|Select|Wrap|Line Numbers
  1. $client = new SoapClient("my.wsdl",array("trace"=>1));
  2. $string = "<! [CDATA[<myxml>]]>";
  3. $client->remoteMethod(array("tagname" => $string));
  4.  
When done this way, $string's tags are converted to &lt; and &gt; but "<tagname>" is proper -- how do I properly pass CDATA to a webservice using the PHP SoapClient?
I think your problem is this:
CDATA tags must start <![CDATA[ and end ]]>
You have a space between the ! and the [
This is incorrect.
Jun 13 '07 #2
brandonkirsch
7 New Member
In my code, I use <![CDATA[start_to_end]]> but since looking at many web examples I often see the tag labeled < ![CDATA[start_to_end]]>. In any case, PHP behaves the same way and escapes the <> tags around CDATA and any <> tags inside of [start_to_end].

How do I properly pass CDATA to a webservice using PHP SoapClient?
Jun 13 '07 #3
Motoma
3,237 Recognized Expert Specialist
In my code, I use <![CDATA[start_to_end]]> but since looking at many web examples I often see the tag labeled < ![CDATA[start_to_end]]>. In any case, PHP behaves the same way and escapes the <> tags around CDATA and any <> tags inside of [start_to_end].

How do I properly pass CDATA to a webservice using PHP SoapClient?
I am not familiar with SoapClient, however from the documentation I have been reading, it appears that the SoapClient is a layer above the type of interactions you are trying to deal with. If you want to be able to send you own formed XML, you will need to utilize curl, otherwise you SoapClient is going to (properly) escape your elements as if there were data segments of its own XML structure.
Jun 13 '07 #4
brandonkirsch
7 New Member
I am not familiar with SoapClient, however from the documentation I have been reading, it appears that the SoapClient is a layer above the type of interactions you are trying to deal with. If you want to be able to send you own formed XML, you will need to utilize curl, otherwise you SoapClient is going to (properly) escape your elements as if there were data segments of its own XML structure.
Motoma thanks for your continued help. Can you tell me what documentation you're looking at? I'm ready to buy a book if there's a good one you can recommend.

I've tried generating a few different objects that are compatible with the native SoapClient param objects but haven't found any. There has got to be a way to specify "This is CDATA" to SoapClient but I haven't figured it out yet.

I also wonder if I change the WSDL parameter from "s:string" to something else ("any" perhaps?) if SoapClient will quit escaping my data.

My current solution has been to use an ssl socket connection and do the HTTP headers myself. It took a lot of effort to get this done and I don't want to repeat it for future webservice calls, that's how I got here.
Jun 13 '07 #5
Motoma
3,237 Recognized Expert Specialist
Motoma thanks for your continued help. Can you tell me what documentation you're looking at? I'm ready to buy a book if there's a good one you can recommend.

I've tried generating a few different objects that are compatible with the native SoapClient param objects but haven't found any. There has got to be a way to specify "This is CDATA" to SoapClient but I haven't figured it out yet.

I also wonder if I change the WSDL parameter from "s:string" to something else ("any" perhaps?) if SoapClient will quit escaping my data.

My current solution has been to use an ssl socket connection and do the HTTP headers myself. It took a lot of effort to get this done and I don't want to repeat it for future webservice calls, that's how I got here.
Just a brief scrub through http://php.net/soap.
It can't hurt to try manipulating the WSDL, post back if you find a solution.
Jun 13 '07 #6
brandonkirsch
7 New Member
Just a brief scrub through http://php.net/soap.
It can't hurt to try manipulating the WSDL, post back if you find a solution.
Motoma, I have read, re-read and triple checked everything about SoapClient on PHP.net - what in there makes you think it's normal for SoapClient to escape your data?
Jun 13 '07 #7
Motoma
3,237 Recognized Expert Specialist
Motoma, I have read, re-read and triple checked everything about SoapClient on PHP.net - what in there makes you think it's normal for SoapClient to escape your data?
A) This is the way it is working.
B) SOAP is an XML envelope to wrap around client data. It is an Abstraction Layer to allow you to interface with Web Services. From what I can tell, you are trying to pass XML to your remote service function. Why not send the raw data?
Jun 13 '07 #8
brandonkirsch
7 New Member
A) This is the way it is working.
B) SOAP is an XML envelope to wrap around client data. It is an Abstraction Layer to allow you to interface with Web Services. From what I can tell, you are trying to pass XML to your remote service function. Why not send the raw data?
Well the remote service function _expects_ me to pass an XML doc CDATA'd up into one parent tag. I think it's a poor implementation on their part because they should just extend the CDATA'd XML to be part of the remote service parameters, but I can't change the way their service runs.

So I _am_ sending the raw data, the issue is that should I run into this again I don't want to spend hours repeating it for a different webservice call. Thanks for all your help, but I think I'm searching in vain. Maybe SoapClient will be better documented after the release of PHP6, or even less likely, I learn C and read straight from the source code LOL
Jun 13 '07 #9
Motoma
3,237 Recognized Expert Specialist
Yes, those are both quite unlikely, aren't they :P

You are missing out on one point that I made earlier: SoapClient and NuSOAP (another PHP SOAP implementation) utilize cURL behind the scenes. You could just write your own SOAP class that wraps cURL and performs the way you need it to.
Jun 13 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6039
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...
1
3442
by: chris | last post by:
Confused somewhat xml newbie. I'm trying to output xml with a CDATA section, using saxutils.XMLGenerator, but the output contains escaped '<' and '>' and '&' from the CDATA element. Shouldn't it be spit out intact? Here's code and output: from xml.sax import saxutils import sys handler = saxutils.XMLGenerator(sys.stdout)
10
2356
by: Simon Brooke | last post by:
Here's my problem: <xsl:template match="/category"> .... <script type="text/javascript"> &lt;!]&gt; </script> .... </xsl:template>
1
3611
by: Dheepu Kumar1 | last post by:
We are using WSDL in soapclient to access the java web service.The soapclient request is not formed as required by the service. Namespace is not included in one ComplexType element(<GSTBTReq>) in request XML which causes the problem in getting response from the service. Request XML generated by SoapClient: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://abc.com/GBTSTo/GBTSTReq/01"...
0
2421
by: kencana | last post by:
hi All, I got problem in passing data (more than one) from soap client to the soap server. but if i only passing one data at a time, it works successfully.. The following is the error message i get when i pass more than one data: "SoapFault exception: looks like we got no XML document in C:\Program Files\MapGuideOpenSource\WebServerExtensions\www\phpviewersample\clienttry2.php:24 Stack trace: #0 : SoapClient->__call('getMap', Array) #1...
0
4760
by: Florian Laws | last post by:
Hello, to work around an interoperability problem with the PHP5 SOAP extension, I'd like to modify the generate XML SOAP request. (as described in http://www.schlossnagle.org/~george/blog/index.php?/archives/235-Salesforce.com-and-PHP.html ) To acheive this, I subclass SoapClient and overwrite the __doRequest() method. According to the PHP documentation and the article above, the
4
2114
by: Mike P2 | last post by:
I used to use arrays in input data that will be turned into a superglobal more often, but now that I care more about xHTML validity, I don't. Validation checking websites (particularly the W3C validator) yell at me for having square brackets in a name or id attribute. I started going the simple way of just separating what would be the array name from what would be the subscript with an underscore and parsing that out with PHP later. Is...
4
14240
by: brandonkirsch | last post by:
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 "GetSessionToken" 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...
0
1099
by: sganeshsvk | last post by:
How to call soapheader function in soapclient php5? I want to call the <soap header> xml in soapclient php. so i want to use soapheader function in soapclient php5. please code for example how to declare soapheader in soapclient. <?php function OrderImport()
0
9720
marktang
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...
0
10372
jinu1996
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...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10112
tracyyun
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...
0
9193
agi2029
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...
0
6879
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();...
0
5546
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...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.