Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 25, 2014 10:41
Show Gist options
  • Save bennadel/9759000 to your computer and use it in GitHub Desktop.
Save bennadel/9759000 to your computer and use it in GitHub Desktop.
AxisFault: ColdFusion Web Services And XML Data Types
<cfcomponent
output="false"
hint="I am a test web service component.">
<cffunction
name="Test"
access="remote"
returntype="string"
output="false"
hint="I take an XML argument.">
<!--- Define arguments. --->
<cfargument
name="Data"
type="xml"
required="true"
hint="I am the xml data."
/>
<!--- Define the local scope. --->
<cfset var LOCAL = {} />
<!--- Get the value. --->
<cfset LOCAL.ValueNodes = XmlSearch(
XmlParse( ARGUMENTS.Data ),
"//value"
) />
<!--- Get the value. --->
<cfset LOCAL.Value = LOCAL.ValueNodes[ 1 ].XmlText />
<!--- Return value. --->
<cfreturn LOCAL.Value />
</cffunction>
</cfcomponent>
<!--- Build our WSDL Url. --->
<cfset strURL = (
"http://localhost" &
GetDirectoryFromPath( CGI.script_name ) &
"WS.cfc?wsdl"
) />
<!--- Build our XML data. --->
<cfsavecontent variable="strData">
<data>
<value>Test</value>
</data>
</cfsavecontent>
<!--- Invoke the web service. --->
<cfinvoke
returnvariable="strResponse"
webservice="#strURL#"
method="Test"
refreshwsdl="true">
<cfinvokeargument name="Data" value="#Trim( strData )#" />
</cfinvoke>
<!--- Output the response. --->
<cfoutput>
#strResponse#
</cfoutput>
<!--- Output ARGUMENTS. --->
<cfdump
var="#ARGUMENTS#"
format="html"
output="#ExpandPath( './dump.htm' )#"
/>
<!--- Define arguments. --->
<cfargument
name="Data"
type="string"
required="true"
hint="I am the xml data."
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment