Coldfusion Web Service / XML

Associate
Joined
12 Mar 2005
Posts
2,021
Location
Scotland
Hey,

Having a few problems getting my web service to work. Not good at Coldfusion and has taken me ages to get to this stage but now iv hit my brick wall. So what i have so far:

XML(this is fine - can manipulate it if needed to make things easyer)
.CFC
.CFM

.CFC
Code:
<cfcomponent>  
<cffunction name="results"              
   access="remote"              
   returntype="struct"              
   output="no" >  
      
   <cfargument name="HomeTeam" type="string" required="yes">
   <cfargument name="AwayTeam" type="string" required="yes">
  
      
   
   <cfset MyXmlFile = Expandpath("UEFA08.xml")>
   <cffile action="READ" variable="xmlInput"  file="#MyXmlFile#">
   <cfset myXML = StructNew() >

<!---Problem Xpath--->
   <cfset myXML.homeName = XmlSearch(MyXmlFile, "/UEFA08/GROUP/MATCHES/MATCH[@mid='LAZBRE']/HOMETEAM/HTEAMNAME")>
<!---End of problem--->

   <cfset myXML.homeGoals = '2'>
   <cfset myXML.homeScorer = 'Home Scorer1'>
   <cfset myXML.homeScorerTime = '9'>
   
   
   <cfset myXML.awayName = 'BRE'>
   <cfset myXML.awayGoals = '1'>
   <cfset myXML.awayScorer = 'Away Scorer1'>
   <cfset myXML.awayScorerTime = '10'>


 <cfreturn #myXML#>  
 </cffunction>
 </cfcomponent>

If u use <cfset myXML.awayGoals = '1'> then this will pass fine. But i cant get it to work using Xpath to search my XML document.

There are lots of diff ideas floating about the net but far to many variables that seem to effect it (and diff ways of doing the same thing).

Thoughts iv had:

Is the XMLparsing properly?
There has been mention of use of ToString() is this needed anywhere?
(after this my thoughts go more towards giving up :p)

.CFM
Code:
<html>
 <head>
 <title>UEFA08 Web Service</title>
 </head>
 <body>
<cfinvoke  
  webservice="http://0603046.studentplus.abertay.ac.uk/ws/times17.cfc?wsdl"
   method="results"  
   returnvariable="answer">  
   <cfinvokeargument name="HomeTeam" value="Lazio"/>
   <cfinvokeargument name="AwayTeam" value="Bremen"/>
</cfinvoke>

<h1>Results</h1><cfoutput>
<h2>#answer.homeName#(#answer.homeGoals#) V's #answer.awayName#(#answer.awayGoals#)</h2> 
<br/>

<h3>#answer.homeName#</h3>
Scorers(Time Scored):
<ol>
	<li>#answer.homeScorer# (#answer.homeScorerTime#)</li>
</ol>


<h3>#answer.awayName#</h3>
Scorers(Time Scored):
<ol>
	<li>#answer.awayScorer# (#answer.awayScorerTime#)</li>
</ol>
</cfoutput>
</body>
</html>

This seems to be fine(works when i dont try the Xpath stuff), but maby its not?


Any help/ideas or pointer would be very much appreciated!!

Thanks
 
Back
Top Bottom