macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

Re: passing xml to a web service

Subject: Re: passing xml to a web service
From: Adam Cameron
Date: Tue, 4 Nov 2008 12:35:01 +1300
Newsgroups: macromedia.coldfusion.advanced_techniques

> 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",
"http://localhost:8305/shared/cf/webservices/sendXml/c.cfc?wsdl";)>

<cfxml variable="x1">
        <aaa>
                <bbb>ccc</bbb>
        </aaa>
</cfxml>

<cfset x2 = o.f(x=x1)>

<cfdump var="#x1#" label="x1">
<cfdump var="#x2#" label="x2">

<!--- c.cfc --->
<cfcomponent>

        <cffunction name="f" access="remote" returntype="xml">
                <cfargument name="x" type="xml" required="true">

                <cfset var a = xmlSearch(arguments.x, "//bbb")>
                <cfset a[1].xmlChildren[1] = xmlElemNew(arguments.x, "ddd")>
                <cfset a[1].xmlChildren[1].xmlText = "eee">
                <cfreturn arguments.x>
        </cffunction>

</cfcomponent>

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!! ;-)


-- 
Adam

<Prev in Thread] Current Thread [Next in Thread>