• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Web Service

New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

In what way does it not work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

sorry when you run this page

http://www.climatetech.net/cti_webservice/Test_WebService.cfm

i get this error


Could not generate stub objects for web service invocation.
Name: http://www.climatetech.net/WebService.cfc?wsdl. WSDL: http://www.climatetech.net/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.

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

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


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

Your first sentence in your OP is "I am trying to learn how to do a webservice." I suggest taking baby steps.

Don't advance to a step until the previous step has been successfully completed.

Step 1.
Write a cfc with one function that accepts no arguments and returns a simple string, like "Hello World".
Step 2.
Invoke it as a cfc
Step 3
Invoke it as a webservice.
Step 4.
Add another function to the cfc that takes a string argument, and returns it.
Step 5.
Invoke it as a cfc
Step 6
Invoke it as a webservice.

You then start building the one you really want. I forget the details, but you might have to refresh your stub objects from time to time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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 :


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2008 Oct 06, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2008 Oct 07, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2008 Oct 07, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2008 Oct 07, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2008 Oct 07, 2008

Copy link to clipboard

Copied

LATEST
Dan is right - it looks like you already have that code :)

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation