• 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 ,
Mar 25, 2008 Mar 25, 2008

Copy link to clipboard

Copied

so i have never created a web service and find my self wanting to learn how. So I found this page with examples

http://www.quackit.com/coldfusion/tutorial/coldfusion_web_services.cfm

i followed the example and built my own script just changing out my database info so it would use my data.


here is my data



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

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

<cfset Var BookList = "">
<cfset Var getBooks = "">
<cfquery name="getBooks" datasource="datasource">
SELECT FileToolID,FileTitle, UrlLink, FileDescription, File3
FROM FileTool
AND FileTool.StatusID = 'Approved'
AND FileTool.FileCONFIGID = 24
</cfquery>

<cfsavecontent variable="BookList">
<books>
<cfoutput query="getBooks">
<book id="#FileToolID#">
<booktitle>#XMLFormat(FileTitle)#</booktitle>
<teaser>#XMLFormat(UrlLink)#</teaser>
<price>#XMLFormat(FileDescription)#</price>
</book>
</cfoutput>
</books>
</cfsavecontent>

<cfreturn BookList>
</cffunction>
</cfcomponent>

i tried to then run this script

<cfinvoke
method="listBooks"
returnvariable="rawXMLBookList"
webservice=" http://yourdomain.com/web_services/book.cfc?wsdl">

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

<cfset computerBooks = XmlParse(rawXMLBookList)>

<cfdump var="#computerBooks#">

and i get nothing but an error. the part i do not get is my first file is called test.cfm do i need to cal lit test.cfc? or does it create a file called test.cfm

this part confuses me.

thanks much

TOPICS
Advanced techniques

Views

510

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 ,
Mar 25, 2008 Mar 25, 2008

Copy link to clipboard

Copied

ps this part webservice=" http://yourdomain.com/web_services/book.cfc?wsdl"> i did put in the link to my file test.cfc

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 ,
Mar 25, 2008 Mar 25, 2008

Copy link to clipboard

Copied

mikey999 wrote:
> so i have never created a web service and find my self wanting to learn how. So
> I found this page with examples
>
> http://www.quackit.com/coldfusion/tutorial/coldfusion_web_services.cfm
>
> i followed the example and built my own script just changing out my database
> info so it would use my data.
>
>
> here is my data
>
>
>
> <cfcomponent>
> <cffunction name="listBooks"
> access="remote"
> returntype="string"
> output="no">
>
> <cfargument name="category"
> type="string"
> required="yes">
>
> <cfset Var BookList = "">
> <cfset Var getBooks = "">
> <cfquery name="getBooks" datasource="datasource">
> SELECT FileToolID,FileTitle, UrlLink, FileDescription, File3
> FROM FileTool
> AND FileTool.StatusID = 'Approved'
> AND FileTool.FileCONFIGID = 24
> </cfquery>
>
> <cfsavecontent variable="BookList">
> <books>
> <cfoutput query="getBooks">
> <book id="#FileToolID#">
> <booktitle>#XMLFormat(FileTitle)#</booktitle>
> <teaser>#XMLFormat(UrlLink)#</teaser>
> <price>#XMLFormat(FileDescription)#</price>
> </book>
> </cfoutput>
> </books>
> </cfsavecontent>
>
> <cfreturn BookList>
> </cffunction>
> </cfcomponent>
>
> i tried to then run this script
>
> <cfinvoke
> method="listBooks"
> returnvariable="rawXMLBookList"
> webservice=" http://yourdomain.com/web_services/book.cfc?wsdl">
>
> <cfinvokeargument name="category" value="123">
> </cfinvoke>
>
> <cfset computerBooks = XmlParse(rawXMLBookList)>
>
> <cfdump var="#computerBooks#">
>
> and i get nothing but an error. the part i do not get is my first file is
> called test.cfm do i need to cal lit test.cfc? or does it create a file called
> test.cfm
>
> this part confuses me.
>
> thanks much
>
>
>


The <cfcomponent...>...</cfcomponent> code should be in a file with a
.cfc extension, this is not required, but it is the default expectation.

The <cfinvoke...> tag should be in an .cfm file. It could also be in a
higer level cfc, but let's not get ahead of ourselves here. The
"webservice" parameter of the <cfinvoke...> tag should reference the cfc
file created above.

Before running your cfc as a web service run it as a component. Just
add a component version of <cfinvoke...> before your web service
version. This makes sure that errors in the cfc itself is not stopping
you dead in your tracks. A web service can not always report the same
level of detail about an error as a component called locally can.

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 ,
Mar 26, 2008 Mar 26, 2008

Copy link to clipboard

Copied

well i am getting this error maybe this will help some

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


Could not perform web service invocation "listBooks".
Here is the fault returned when invoking the web service operation:

AxisFault
faultCode: { http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.tagext.sql.QueryTag$DatabaseQueryException : Error Executing Database Query.][java.sql.SQLException : [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'AND'.]
faultActor:
faultNode:
faultDetail:
{ http://xml.apache.org/axis/}stackTrace:coldfusion.xml.rpc.CFCInvocationException: [coldfusion.tagext.sql.QueryTag$DatabaseQueryException : Error Executing Database Query.][java.sql.SQLException : [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'AND'.]
at coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponentSkeleton.java:714)
at coldfusion.xml.rpc.CFComponentSkeleton.__invoke(CFComponentSkeleton.java:660)
at login.test.listBooks(D:\login\test.cfc)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAcce...


The error occurred in D:\login\test2.cfm: line 6

4 : webservice=" http://www.resourcesaver.com/login/test.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 ,
Mar 26, 2008 Mar 26, 2008

Copy link to clipboard

Copied

SELECT FileToolID,FileTitle, UrlLink, FileDescription, File3
FROM FileTool
AND FileTool.StatusID = 'Approved'
AND FileTool.FileCONFIGID = 24

that is a very wrong sql statement, which is what your webservice is
trying to tell you with the error...

see what and WHERE you are missing in your sql?

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 ,
Mar 26, 2008 Mar 26, 2008

Copy link to clipboard

Copied

i fixed that error in my query you are right i missed out a where but still getthis this error

i also noticed in side the cfm admin there is a place for web service but this example does not talk about this at all. Do i need to do anything in that cfm admin on this for this to work?

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

Could not perform web service invocation "listBooks".
Here is the fault returned when invoking the web service operation:

AxisFault
faultCode: { http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.tagext.sql.QueryTag$DatabaseQueryException : Error Executing Database Query.][java.sql.SQLException : [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'UrlLink'.]
faultActor:
faultNode:
faultDetail:
{ http://xml.apache.org/axis/}stackTrace:coldfusion.xml.rpc.CFCInvocationException: [coldfusion.tagext.sql.QueryTag$DatabaseQueryException : Error Executing Database Query.][java.sql.SQLException : [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'UrlLink'.]
at coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponentSkeleton.java:714)
at coldfusion.xml.rpc.CFComponentSkeleton.__invoke(CFComponentSkeleton.java:660)
at login.test.listBooks(D:\login\test.cfc)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Nati...


The error occurred in D:\web\getfsites\getf\test2.cfm: line 6

4 : webservice=" http://www.resourcesaver.com/login/test.cfc?wsdl">
5 :
6 : <cfinvokeargument name="category" value="123">
7 : </cfinvoke>
8 :



--------------------------------------------------------------------------------

Resources:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.


Browser Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
Remote Address 64.243.182.132
Referrer
Date/Time 26-Mar-08 03:41 PM



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 ,
Mar 26, 2008 Mar 26, 2008

Copy link to clipboard

Copied

LATEST
just READ the error you get:

faultString: coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.tagext.sql.QueryTag$DatabaseQueryException : Error Executing
Database Query.][java.sql.SQLException : [Macromedia][SQLServer JDBC
Driver][SQLServer]Invalid column name 'UrlLink'.]

*Invalid column name 'UrlLink'*

you apparently still have your query wrong...


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