// Copyright  2002 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.


	=1=	on fetch_SOAP_lite(endpoint, method, p)
	=2=	  using terms from application "http://www.apple.com/placebo"
	=3=	    tell application endpoint to return call soap {method name:method, method namespace uri:endpoint, SOAPAction:(endpoint & "#" & method), parameters:p}
	=4=	  end using terms from
	=5=	end fetch_SOAP_lite
	=6=	
	=7=	on fetch_headlines(uri)
	=8=	  return fetch_SOAP_lite("http://localhost:8001/Server", "fetch_headlines", {uri:uri})
	=9=	end fetch_headlines
	=10=	
	=11=	set response to fetch_headlines("http://www.perl.com/pace/perlnews.rdf")
	=12=	set output to "<ul>" & return
	=13=	repeat with i in response
	=14=	  set output to output & "<li><a href=\"" & (i's link) & "\">" & (i's title) & "</a></li>" & return
	=15=	end repeat
	=16=	set output to output & "</ul>" & return
	=17=	set output_file to (path to temporary items folder as string) & "fetch_headlines.html"
	=18=	write_to_file(output, output_file, false)
	=19=	tell application "Finder" to open output_file
	=20=	
	=21=	-- written by some smarter person
	=22=	on write_to_file(this_data, target_file, append_data)
	=23=	  try
	=24=	    set the target_file to the target_file as text
	=25=	    set the open_target_file to 
	=26=	      open for access file target_file with write permission
	=27=	    if append_data is false then 
	=28=	      set eof of the open_target_file to 0
	=29=	    write this_data to the open_target_file starting at eof
	=30=	    close access the open_target_file
	=31=	    return true
	=32=	  on error
	=33=	    try
	=34=	      close access file target_file
	=35=	    end try
	=36=	    return false
	=37=	  end try
	=38=	end write_to_file