Skip to main content
Inspiring
September 26, 2006
Question

consuming a webservice

  • September 26, 2006
  • 18 replies
  • 1480 views
I am attempting to create a webservice from one site to be consumed by
another site. I have gone through various webservices tuts in the
distant past but I am stuck on this one.

On server A I have the following CFC...

<cfcomponent hint="Returns minimal member data for consumption">

<cffunction name="getMembersbyState" access="public" returntype="query"
hint="Members by State" description="FInd and return member listing by
state">
<cfargument name="state" required="yes" default="">
<cfset var rsGetResults="">
<cfquery name="rsGetMembers" datasource="#request.dsn#"
username="#request.dsnusrnm#" password="#request.dsnpwd#" >
SELECT member_id, city as member_City, company_name as member_Name,
dba_name as member_DBA
FROM members_tbl
WHERE Active = 1
AND state = '#argument.state#'
ORDER BY company_name
</cfquery>
<cfreturn rsGetMembers>
</cffunction>
</cfcomponent>

Now simply browsing to this page on my local server results in the cfc
description details. Browsing to in on the server - results in the
following error...

Could not import the tag library specified by "../administrator/cftags/".
The following error was encountered:
D:\inetpub\wwwroot-ct\CFIDE\componentutils\..\administrator\cftags.
Please ensure that you have specified a valid tag library.

The CFML compiler was processing:

* a cfimport tag beginning on line 3, column 2.


The error occurred in
D:\inetpub\wwwroot-ct\CFIDE\componentutils\login.cfm: line 3
Called from D:\inetpub\wwwroot-ct\CFIDE\componentutils\Application.cfm:
line 55
Called from D:\inetpub\wwwroot-ct\CFIDE\componentutils\Application.cfm:
line 55

1 : <cfsilent>
2 : <!--- Import L10N Taglib (System Generated) --->
3 : <cfimport prefix="admin" taglib="../administrator/cftags/">
4 :
5 : <!--- Establish page locale, default is english (en). --->


Does anyone have any pointers? PLEASE.

I have attempted to map the custom tag path to my cfc folder in the site
- via the system control panel. ( Using Crystaltech as host)
Should I be creating a diff. mapping of some kind? I can add a mapping
instead of a custom tag path but I have never done this thing before so
I completely lost.

Thanks so much.
Chris
This topic has been closed for replies.

18 replies

Inspiring
September 27, 2006
I am starting to get a hold on this I think. Part of what confused me
is that the directory structure you mentioned below Tim - is not in ANY
of my files. I believe it is referenced on the host server in some manner.

My cfc has five lines at this point and says simply this...

<cfcomponent hint="Returns minimal member data for consumption">
<cffunction name="firstws" access="remote" returntype="string">
<cfreturn "DevNet is great!">
</cffunction>
</cfcomponent>

If you look at my original post with the complex function in it - it
also has no reference to the administrator/cftags directory. So I am at
a loss except that the host is forcing this tag library to be imported
in some way.


As for the robust error handling - I am not sure why the cfc gives me
this error b/c if you break the rest of the site - I am emailed a report
and the user is displayed a simple request or exception error as I
making use of the cferror tag in my application.cfm file in this manner...

<cferror type="request" template="ErrorRequest.cfm" mailto="xxxx.xxxx.com">
<cferror type="exception" template="ErrorException.cfm"
mailto="xxxx.xxxx.com">

If you know of a better way please let me know - If I am missing
something I am not afraid to ask.

Thanks Tim,
Chris

cecropin wrote:
> Chris,
>
> I tried those links above and read the error message. It seems very clear to
> me that the problem is the directory you are referencing "administrator/cftags"
> is not located where you think it is or where you think CF will begin looking
> for it. When you put "../administrator/cftags" CF starts from the current
> directory of the template w/ the cfimport. It goes up one directory, then down
> to administrator and cftags. Does this reflect your directory structure? I'm
> guessing not.
>
> The WSDL will work, because your webservice function is properly formatted and
> unless the code is executed you will not encounter the error you are
> experiencing. You are not referencing anything in CF mappings because you've
> got ".." in taglib attribute. The CFDocs are clear on this, either you
> reference from the webroot with a leading "/", reference a cfmapping with a
> leading "/, or the path is relative from the current directory of the template.
>
> http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/
> wwhelp.htm?context=ColdFusion_Documentation&file=part_cfm.htm
>
> BTW, I'm not sure if you did this to debug or if it's always like this but
> since your app is out on the Internet I highly recommend you disable robust
> exceptions once you're done. Use a global error handler to log the error
> and/or email the details to you.
>
> -Tim
>

--
Chris Luksha
Echo Web Services
Making Your Website Resound
603-831-0099
http://www.echowebservices.com/

CAN-SPAM Compliant Email Newsletters - only $.05 per Subscriber
http://www.echowebservices.com/email
Inspiring
September 27, 2006
I merely stuck in some basic application 'stuff' b/c I had read quite a
few posts of the same troubles (some of them anyway) and the simple
inclusion of an application file in the same directory with the cfc
resolved some things. It did not for me.
Try the links now. I have removed the application.cfm file.

Ian Skinner wrote:
> http://www.femsa.org/cfc/getMembers.cfc?WSDL This outputs as expected.
> http://www.femsa.org/cfc/getMembers.cfc Yells at me.
>
>
> I received this error for both of these links.
> 5 >= 0
>
> The error occurred in D:\inetpub\femsa\cfc\application.cfc: line 1
>
> 1 : <cfapplication name = "cfc">
> 2 : <cfset request.dsn="femsaDSN">
> 3 : <cfset request.dsnusrnm="spartacus">
>
>
> Check into the documentation for using an application.cfc with web
> services and the request functions. They have some very specific
> interactions, and the documentation gives some warnings on what you can
> and can not do if you want to publish a web service.

--
Chris Luksha
Echo Web Services
Making Your Website Resound
603-831-0099
http://www.echowebservices.com/

CAN-SPAM Compliant Email Newsletters - only $.05 per Subscriber
http://www.echowebservices.com/email
September 26, 2006
Chris,

I tried those links above and read the error message. It seems very clear to me that the problem is the directory you are referencing "administrator/cftags" is not located where you think it is or where you think CF will begin looking for it. When you put "../administrator/cftags" CF starts from the current directory of the template w/ the cfimport. It goes up one directory, then down to administrator and cftags. Does this reflect your directory structure? I'm guessing not.

The WSDL will work, because your webservice function is properly formatted and unless the code is executed you will not encounter the error you are experiencing. You are not referencing anything in CF mappings because you've got ".." in taglib attribute. The CFDocs are clear on this, either you reference from the webroot with a leading "/", reference a cfmapping with a leading "/, or the path is relative from the current directory of the template. http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=part_cfm.htm

BTW, I'm not sure if you did this to debug or if it's always like this but since your app is out on the Internet I highly recommend you disable robust exceptions once you're done. Use a global error handler to log the error and/or email the details to you.

-Tim
Inspiring
September 26, 2006
Another thought that just occurred to me. You can not use normal state
creating functionality with web services. They do not pass the CF
tokens that are required for session state management.
Inspiring
September 26, 2006
http://www.femsa.org/cfc/getMembers.cfc?WSDL This outputs as expected.
http://www.femsa.org/cfc/getMembers.cfc Yells at me.


I received this error for both of these links.
5 >= 0

The error occurred in D:\inetpub\femsa\cfc\application.cfc: line 1

1 : <cfapplication name = "cfc">
2 : <cfset request.dsn="femsaDSN">
3 : <cfset request.dsnusrnm="spartacus">


Check into the documentation for using an application.cfc with web
services and the request functions. They have some very specific
interactions, and the documentation gives some warnings on what you can
and can not do if you want to publish a web service.
Inspiring
September 26, 2006
I thought it might be worth someone being able to see the link and test
it themselves :)

http://www.femsa.org/cfc/getMembers.cfc?WSDL This outputs as expected.
http://www.femsa.org/cfc/getMembers.cfc Yells at me.

I have added the firstws method as shown in this article...
http://www.adobe.com/devnet/coldfusion/articles/beginner_ws.html

Accessing the wsdl link from outside the server now reports this
error... Web service operation "firstws" with parameters {} could not
be found.


Ian Skinner wrote:
> The first thing I noticed was that your access is wrong. For a function
> to be a web service it needs to be access="remote" not access="public".
>
> Also you might try returning a simple string until you know you have the
> web service running and connecting, then move up to complex variables
> like a query record set.

--
Chris Luksha
Echo Web Services
Making Your Website Resound
603-831-0099
http://www.echowebservices.com/

CAN-SPAM Compliant Email Newsletters - only $.05 per Subscriber
http://www.echowebservices.com/email
Inspiring
September 26, 2006
Sorry 'bout that. I have tried the remote and was testing public.
forgot to put it back. Anyway thanks for the simplicity test.

A note: if I run the file directly on the server with the ?wsdl - I do
in fact get what I expect.



Ian Skinner wrote:
> The first thing I noticed was that your access is wrong. For a function
> to be a web service it needs to be access="remote" not access="public".
>
> Also you might try returning a simple string until you know you have the
> web service running and connecting, then move up to complex variables
> like a query record set.

--
Chris Luksha
Echo Web Services
Making Your Website Resound
603-831-0099
http://www.echowebservices.com/

CAN-SPAM Compliant Email Newsletters - only $.05 per Subscriber
http://www.echowebservices.com/email
Inspiring
September 26, 2006
The first thing I noticed was that your access is wrong. For a function
to be a web service it needs to be access="remote" not access="public".

Also you might try returning a simple string until you know you have the
web service running and connecting, then move up to complex variables
like a query record set.