Skip to main content
Known Participant
October 6, 2008
Question

Web Service

  • October 6, 2008
  • 12 replies
  • 1460 views
hi,

i am trying to learn how to do a web service.

I used this example to figure this out
http://www.quackit.com/coldfusion/tutorial/coldfusion_web_services.cfm

my code is here
http://www.climatetech.net/cti_webservice/Test_WebService.cfm

Code
===============================================

<cfinvoke
method="listBooks"
returnvariable="rawXMLFileList"
webservice=" http://www.climatetech.net/WebService.cfc?wsdl">

<cfinvokeargument name="category" value="123">
</cfinvoke>

<cfset FilesXML = XmlParse(rawXMLFileList)>

<cfdump var="#FilesXML#">

========================================
and my cfc file is here
http://www.climatetech.net/cti_webservice/WebService.cfc

code



<cfcomponent>
<cffunction name="listBooks"
access="remote"
returntype="string"
output="no">

<cfargument name="category"
type="string"
required="yes">

<cfset Var FileList = "">
<cfset Var getBooks = "">
<cfquery name="getBooks" datasource="DS" maxrows=100 dbtype="ODBC">
SELECT FileToolID,FileTitle, FileDescription, File3
FROM FileTool
Where FileTool.StatusID = 'Approved'
AND FileTool.FileCONFIGID = 24
</cfquery>
<cfsavecontent variable="FileList">
<Files>
<cfoutput query="getBooks">
<File id="#FileToolID#">
<Filetitle>#XMLFormat(FileTitle)#</Filetitle>
<FileLink> http://www.resourcesaver.org/file/toolmanager/#XMLFormat(File3)#</FileLink>
<Description>#XMLFormat(FileDescription)#</Description>
</File>
</cfoutput>
</Files>
</cfsavecontent>

<cfreturn FileList>
</cffunction>
</cfcomponent>


=========================================================

this is really basic but for some reason i can not get this to work. has any one set one of these up and made it work before. i have never done this before but i figure get a basic example working first to understand this.
This topic has been closed for replies.

12 replies

Inspiring
October 7, 2008
Dan is right - it looks like you already have that code :)

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
October 7, 2008
yes, i hear you. i remember when i was working with ws a lot, that was a
real pain in the &^%... i can't recall now, but i think i have found
some piece of code somewhere that programmatically removed the stubs /
refreshed the ws... i will try to dig it up if i can...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
mikey999Author
Known Participant
October 7, 2008
Hi Azadi

ya i think i got it working. I do not see any errors anymore and my test works pretty good. I guess if you change stuff you need to delete the files in the stub directory in cfm to make the changes take effect. Its a very strange thing if you ask me.
Inspiring
October 7, 2008
quote:

Originally posted by: mikey999
Hi Azadi

ya i think i got it working. I do not see any errors anymore and my test works pretty good. I guess if you change stuff you need to delete the files in the stub directory in cfm to make the changes take effect. Its a very strange thing if you ask me.

Not necessarily. You already found the code to refresh your stub objects. You just have to run it once in awhile while you are developing your code.
Inspiring
October 7, 2008
did you even look at the error message?

coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.runtime.UndefinedVariableException :
*Variable FileToolID is undefined*.]

your cfc still has errors.

the best way to troubleshoot this, is to make it into a regular cfc, not
a ws, and invoke it directly using <cfinvoke> or createobject(). test it
thoroughly to make sure it works/returns a meaningful error in all
situations before making it into a ws.


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
mikey999Author
Known Participant
October 6, 2008
ok i think i may have got this work to work finally. maybe this is related to the stub directory? not sure man this is confusing for a newbies on this subject.
mikey999Author
Known Participant
October 6, 2008
i saw another thread that says i need to deelte the files in the stubs directory of cfm can anyone tell me is this the case?
mikey999Author
Known Participant
October 6, 2008
so here is the error i get now


Could not generate stub objects for web service invocation.
Name: http://www.climatetech.net/cti_webservice/WebService.cfc?wsdl. WSDL: http://www.climatetech.net/cti_webservice/WebService.cfc?wsdl. org.xml.sax.SAXException: Fatal Error: URI=null Line=31: The string "--" is not permitted within comments. It is recommended that you use a web browser to retrieve and examine the requested WSDL document for correctness. If the requested WSDL document can't be retrieved or it is dynamically generated, it is likely that the target web service has programming errors.

The error occurred in D:\web\customers\CTI\cti_webservice\Test_WebService.cfm: line 8

6 : webservice=" http://www.climatetech.net/cti_webservice/WebService.cfc?wsdl">
7 :
8 : <cfinvokeargument name="category" value="123">
9 : </cfinvoke>
10 :


mikey999Author
Known Participant
October 6, 2008
ok so i removed that security code and took away the robust errors. I no longer get an error. So I think that the security srcipts run caused the orginal error. But still the script just runs and runs and then just times out. Is there any place i can find a simple example on how to pull 3 fields out of a database into a web service.

Something like this example
http://www.quackit.com/coldfusion/tutorial/coldfusion_web_services.cfm

please anyone i really need to get this up and any help on this and i will be so thankful
Inspiring
October 6, 2008
when i try to access
http://www.climatetech.net/cti_webservice/WebService.cfc?wsdl

i get this:
Variable Form is undefined.

The error occurred in D:\login\unsecure\Security_Check.cfm: line 3
Called from D:\login\unsecure\RegistrationApplication.cfm: line 1
Called from D:\web\customers\CTI\Application.cfm: line 9

1 :
2 : <!--- Check that form inputs don't have any <script> tags --->
3 : <cfset keys = StructKeyArray(Form)>
4 : <cfif ArrayLen(keys) GT 0>
5 : <cfscript>

is this YOUR ws? did YOU write it? there are obviously errors in it. so
if it is yours - correct those errors (and please, turn off robust
exception info on the production server!). if it is not yours - contact
the company that provides this ws and notify them of the errors.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
mikey999Author
Known Participant
October 6, 2008
what is a stub objects? this code used to work like 5 months ago. I never did anything to it and it just stopped working.

I google stub service and found where someone suggest to run something like this


<cfobject type="JAVA"
action="Create"
name="factory"
class="coldfusion.server.ServiceFactory">

<cfset RpcService = factory.XmlRpcService>

<cfset RpcService.refreshWebService(" http://www.climatetech.net/cti_webservice/Test_WebService.cfm")>




but when i do i get this error

Could not generate stub objects for web service invocation.
Name: http://www.climatetech.net/cti_webservice/WebService.cfc?wsdl. WSDL: http://www.climatetech.net/cti_webservice/WebService.cfc?wsdl. org.xml.sax.SAXException: Fatal Error: URI=null Line=30: The string "--" is not permitted within comments. It is recommended that you use a web browser to retrieve and examine the requested WSDL document for correctness. If the requested WSDL document can't be retrieved or it is dynamically generated, it is likely that the target web service has programming errors.


i built this web service for a not for profit as we are also a not for profit company and so we have a real lack of resources to get out side help so any help i am thankful for big time.