This content has been marked as final. Show 7 replies
It's pretty difficult to divine what your problem might be without actually
seeing any of your code.
It's not really a problem per se, I just want to know how to pass data into a CF web service with an argument type of XML. Being able to access the XML just like you would any CF XML variable within the web service. I can't seem to get it to work, so if anyone has done this I would appreciate any insight.
> It's not really a problem per se, I just want to know how to pass data into a
> CF web service with an argument type of XML. Being able to access the XML just
> like you would any CF XML variable within the web service. I can't seem to get
> it to work, so if anyone has done this I would appreciate any insight.
It works the way you describe it. So given what you are describing doesn't
seem to match what you're experiencing, I think perhaps looking at the code
might be helpful.
However rather than you just copy and paste what you've got so I can say
"oh, hang on... that's not right", I've wasted some of my own time to write
a proof of concept for you.
<!--- caller.cfm --->
<cfset o = createObject("webservice",
<cfset x2 = o.f(x=x1)>
<cfdump var="#x1#" label="x1">
<cfdump var="#x2#" label="x2">
<!--- c.cfc --->
<cffunction name="f" access="remote" returntype="xml">
<cfargument name="x" type="xml" required="true">
<cfset var a = xmlSearch(arguments.x, "//bbb")>
<cfset a.xmlChildren = xmlElemNew(arguments.x, "ddd")>
<cfset a.xmlChildren.xmlText = "eee">
Now, you see I don't know if that is actually some help for you, or even
addresses your problem. But it at least demonstrates passing XML in, and
back out, of a web service.
If it doesn't cast any light on the scene... POST YOUR CODE!! ;-)
I expect Adam's method to work when the caller and the service are both in Coldfusion. However, a web service in .NET or Java might not know what to make of the XML variable, x1.
There was a similar question in the forum some months ago. The universal way to pass an XML variable to a web service is by means of SOAP.
> I expect Adam's method to work when the caller and the service are both in
> Coldfusion. However, a web service in .NET or Java might not know what to make
> of the XML variable, x1.
True. But I figured when the OP said " I tried doing a cfdump to a file
within the web service" it pretty much demonstrated that the web service
*is* a CF one.
Although the reverse could be true: the calling code might not be CF. It's
harder to tell, based on what the OP is saying here, one way or the other.
It would be a lot less ambiguous and require less guessing if... [drum
roll]... we could see some code.
Ok, Thank You Adam for wasting your time to help me. Yes that worked. I didn't post any code because all I had was like four lines, I was trying to publish a ColdFusion webservice, another person has the consuming part. So this is all it was:
<cffunction name="myFunction" access="remote">
<cfargument name="myArg" type="XML" required="true">
<cfdump var="#arguments.myArg#" output="c:\myoutput.txt">
The problem was that the dump was the definition of the java object, not the XML. I didn't know how to access the XML part, or if it existed, which the xmlsearch does. Also, all the namespace prefixes are changed when the XML comes in, so if you have a tag like <myns:myelem></myns:myelem>, when it comes into the CF web service it's changed to <ns1:myelem></ns1:myelem>.
So the combination of those two was throwing me off.
Thanks for the help,
Adam Cameron wrote:
I figured when the OP said " I tried doing a cfdump to a file
within the web service" it pretty much demonstrated that the
web service *is* a CF one.
My post was a note of caution meant for Jim1234. Using SOAP would avoid some of the problems he has mentioned.
Your code looks good, no question about that. More, it answers the question.