|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Dynamic XML(DOM)
Author: LSD 4Me
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308764
Brad,
This may work even better as this will probably allow for a better integration. I
will start messing around with it now. THANKS!
Author: Brad Wood
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308761
Well, heck-- you're making this harder than it has to be. You don't
need a "full blown API"-- ColdFusion does all the SOAP nonsense for you!
If you are calling a SOAP web service, all you need is a couple lines of
code. Check out:
http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applicat
ions_with_CFML/webservices4.htm
Two simple examples (copied from that page) would be:
<cfinvoke
webservice = "http://www.xmethods.net/sd/2001/BabelFishService.wsdl"
method = "BabelFish"
translationmode = "en_es"
sourcedata = "Hello world, friend"
returnVariable = "foo">
<cfoutput>#foo#</cfoutput>
Or...
<cfscript>
ws = CreateObject("webservice",
"http://www.xmethods.net/sd/2001/BabelFishService.wsdl");
xlatstring = ws.BabelFish("en_es", "Hello world, friend");
writeoutput(xlatstring);
</cfscript>
All the SOAP stuff happens in the background and you get a regular
ColdFusion variable back.
I don't know what kind of variable your web service is returning (array,
string, complex type, ect), but looking at the WSDL will tell you that.
~Brad
"...When you say XML data, you're not referring to a SOAP packet are
you?"
Yes, it is a SOAP packet returned in XML format. The API that was
written for the remote webservice has plenty of SOAP related requests
but we are using the HTTP POST method insteatd of creating a full blown
API on our
side.
Author: LSD 4Me
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308759
Dominic!!!!
You the man. Thats exactly what i neeeded. Now that I can have the data parsed I
can manipulate it.
THANK YOU SO MUCH!!!!!
Author: LSD 4Me
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308758
"...When you say XML data, you're not referring to a SOAP packet are you?"
Yes, it is a SOAP packet returned in XML format. The API that was written for the
remote webservice has plenty of SOAP related requests but we are using the HTTP
POST method insteatd of creating a full blown API on our side.
Author: Brad Wood
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308755
Did you read my post? I explained how to parse the xml data. It was
the part of the code that used the xmlparse() function. (Imagine that!)
:)
When you say XML data, you're not referring to a SOAP packet are you?
Perhaps you could post your code that calls the web service so we could
get a better handle on what you are doing.
~Bard
"...I don't know how you are receiving the XML, but for example, it it
was
in a string variable called "my_xml_string_variable", all you need to do
is:"
This is where the confusion is. I am not sure how to parse the XML data
that is returned into a variable. You are correct in that the XML is
returned from a remote web service. What i am trying to do is take the
results, put them into an array and then more likely than not insert it
into a local DB.
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308756
Oops, my code shoulda looked like:
<cfhttp url="http://myurl.com" method="POST">
<cfhttpparam ...>
</cfhttp>
<cfset xml_doc = xmlparse(cfhttp.filecontent)>
<cfdump var="#xml_doc#">
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308753
No it won't. For that, your best bet is to use cfhttp to post the data
and store the resultant output as a variable:
<cfhttp url="http://myurl.com" method="POST">
<cfhttpparam ...>
</cfhttp>
<cfset xmlContent = cfhttp.fileContent>
<cfset xml_doc = xmlparse(cfhttp.filecontent)>
<cfdump var="#xml_doc#">
I'm not sure of the cfhttp syntax off the top of my head (don't copy
and paste that) but that should get you started on the right path.
HTH
Dominic
> Dominic,
>
> The remote webservice requires data to be POSTed to it and will not accept
GET. Will the xmlparse work with POST
requests?
Author: LSD 4Me
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308751
Dominic,
The remote webservice requires data to be POSTed to it and will not accept GET.
Will the xmlparse work with POST requests?
Author: LSD 4Me
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308749
"...I don't know how you are receiving the XML, but for example, it it was
in a string variable called "my_xml_string_variable", all you need to do
is:"
This is where the confusion is. I am not sure how to parse the XML data that is
returned into a variable. You are correct in that the XML is returned from a
remote web service. What i am trying to do is take the results, put them into an
array and then more likely than not insert it into a local DB.
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308748
----- Excess quoted text cut - see Original Post for more -----
Or, if you have an URL that outputs the XML, you can do:
<cfset xml_doc = xmlparse("http://www.myxmloutput.com/?foo=bar&l=45")>
<cfdump var="#xml_doc#">
ColdFusion will recognise that you are passing the parser an URL and
request the output of it as its XML input. Pretty handy really!
HTH
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Brad Wood
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308746
I'm not sure what you mean by " results are returned directly in the
browser in XML format", but I'll ignore that for now and assume you are
calling some webservice, or cfhttping to a URL.
Have the administrators of the "remote database" provided you with an
XSD or DTD which lets you know what the XML will look like?
As long as the format of the XML (what tags and attributes there are) is
predictable, it doesn't really matter whether or not you are using XML
that was created dynamically or read from a static file-- your code will
work the same way.
ColdFusion has some VERY handy ways to deal with XML, but it may help
you to think of ColdFusion's representation of an XML object as an array
of structs.
I don't know how you are receiving the XML, but for example, it it was
in a string variable called "my_xml_string_variable", all you need to do
is:
<cfset xml_doc = xmlparse(my_xml_string_variable)>
<cfdump var="#xml_doc#">
That should at least get you started.
~Brad
Hi
I am currenlty using a form to search for dates in a remote database.
The results are returned directly in the browser in XML format. I need
to setup a way to have that xml data returned dynamicaly to a page which
will then give me the ability to manipulate the data returned (either
display in html form or insert into a local db)
We are on CF8 and im like a deer in headlights when it comes to xml.
does anybody know a good starting point? Ive researched plenty but ALL
the examples require an xml file to already exist on not be generated
dynamically.
Any help is appreciated! THanks!!
Author: LSD 4Me
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56954#308743
Hi
I am currenlty using a form to search for dates in a remote database. The results
are returned directly in the browser in XML format. I need to setup a way to have
that xml data returned dynamicaly to a page which will then give me the ability
to manipulate the data returned (either display in html form or insert into a
local db)
We are on CF8 and im like a deer in headlights when it comes to xml. does anybody
know a good starting point? Ive researched plenty but ALL the examples require an
xml file to already exist on not be generated dynamically.
Any help is appreciated! THanks!!
|
May 24, 2012
|
Latest Fusion Authority Articles
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||