Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / September 2006



Tip: Looking for answers? Try searching our database.

consuming a webservice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Luksha - 26 Sep 2006 21:23 GMT
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
Ian Skinner - 26 Sep 2006 21:28 GMT
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 - 26 Sep 2006 21:34 GMT
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.

> 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.

Signature

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

Chris Luksha - 26 Sep 2006 21:41 GMT
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.

> 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.

Signature

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

Ian Skinner - 26 Sep 2006 21:59 GMT
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 - 27 Sep 2006 03:16 GMT
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.

> http://www.femsa.org/cfc/getMembers.cfc?WSDL  This outputs as expected.
> http://www.femsa.org/cfc/getMembers.cfc  Yells at me.
[quoted text clipped - 12 lines]
> interactions, and the documentation gives some warnings on what you can
> and can not do if you want to publish a web service.

Signature

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

Ian Skinner - 26 Sep 2006 22:03 GMT
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.
cecropin - 26 Sep 2006 23:58 GMT
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 - 27 Sep 2006 03:26 GMT
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

> Chris,
>
[quoted text clipped - 22 lines]
>
>   -Tim

Signature

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

cecropin - 27 Sep 2006 22:38 GMT
Chris,

I apologize.  I must have been a bit sleepy yesterday when I answered this
question.  There are a couple of things going on.  The first is that your
webservice component is working just fine at this time.  I'll get back to that
in a second.

When you use the URL http://www.femsa.org/cfc/getMembers.cfc, it in turn
redirects you to
http://www.femsa.org/CFIDE/componentutils/cfcexplorer.cfc?method=getcfcinhtml&na
me=cfc.getMembers&path=/cfc/getMembers.cfc
which is where you're really getting the error message.  What's happening here
is that you are actually invoking an out of the box CF application with
inspects your CFC.  The error that you're getting is because CF is unable to
find the directory D:\inetpub\wwwroot-ct\CFIDE\administrator\cftags.  I think
CFIDE is a virtual directory and either the security settings are so tight that
the service account running ColdFusion cannot access the administrator/cftags
directory or there's something wrong w/ the install.  For instance I was able
to locate this resource http://www.femsa.org/CFIDE/images/required.gif, but not
http://www.femsa.org/CFIDE/administrator/aboutcf.cfm or
http://www.femsa.org/CFIDE/administrator/cfadmin.css

Getting back to the webservice you should test it like so
http://www.femsa.org/cfc/getMembers.cfc?method=firstws and
http://www.femsa.org/cfc/getMembers.cfc?method=members.

The global error handler in your app is not executing, because application.cfm
from D:\inetpub\wwwroot-ct\CFIDE\componentutils\Application.cfm is being
executed and that doesn't have an error handler.

Does this make sense so far?  At this point it's either a permissions or
install issue happening when you try to inspect your CFC, but I think this is
besides the point, because your original question was about your
getMembersByState webservice.  Can you put that function back in and then  use
a method call like
http://www.femsa.org/cfc/getMembers.cfc?method=getMembersByState&state=IL or
whatever is appropriate for your service.

Looking at your original code. I only see 2 issues, 1 the access must be
remote.  This was pointed out, and 2 you must use the "arguments" scope w/ an s
at the end not "argument".

Hope this helps.

 -Tim
Chris Luksha - 28 Sep 2006 15:13 GMT
Tim - Thank you so much, that at least explained to me what in the world
I was doing wrong in testing the silly thing.  So now I have put back
the original query function to pull all the data.  And using this link
as you mentioned
http://www.femsa.org/cfc/getMembers.cfc?method=getMembersByState&state=IL
works great.  You can even still call
http://www.femsa.org/cfc/getMembers.cfc?method=members and get the silly
little text.

Now I m probably just not understanding how to call the cfc at this
point.  I thought I had it right but I am getting a blank page when
calling the cfc from another domain via cfinvoke.

Here is what I am doing...

The cfc states this:

    <cffunction name="getMembersByState" access="remote" returntype="query"
hint="Members by State" description="FInd and return member listing by
state">
        <cfargument name="state" required="yes" default="">
        <cfset var rsGetMembers="">
            <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 = '#arguments.state#'
                ORDER BY company_name
            </cfquery>
        <cfreturn rsGetMembers>
    </cffunction>

The cfinvoke states this:

<cfinvoke webservice="http://www.femsa.org/cfc/getMembers.cfc?wsdl"
    method="getMembersByState"
    returnvariable="rsGetMembers">
    <cfinvokeargument name="state" value="al"/>
</cfinvoke>

<cfoutput query="rsGetMembers">
    #member_name#<br />
</cfoutput>

Now I would think this should return a list of member names - or at
least if I used a cfdump - I would see the whole thing.  But niether the
code above, nor a cfdump results in anythin on the page.

Am I missing somehting in how I call the cfc?

Thanks for all the patience and help Tim,
Chris

> Chris,
>
[quoted text clipped - 41 lines]
>
>   -Tim

Signature

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

Chris Luksha - 28 Sep 2006 15:20 GMT
I was getting a blank page merely b/c I had turned on error handling and
had not actual error page defined yet.  I have turned it off and now I
am getting the dreaded

Web service operation "getMembersByState" with parameters {} could not
be found.

YUCK.  Also I had another question - I have a basic understanding of
structures and arrays so I thought this might work as a way to call the
cfinvoke but I can't test it until I have resolved the issue above.  Can
I call the function using argumentcollection="#URL#" if the state is
defined in the url?  But lets worry about the first  problem first right :)

Thanks again,
Chris

> Tim - Thank you so much, that at least explained to me what in the world
> I was doing wrong in testing the silly thing.  So now I have put back
[quoted text clipped - 100 lines]
>>
>>   -Tim

Signature

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

Ian Skinner - 28 Sep 2006 15:33 GMT
<cfinvoke webservice="http://www.femsa.org/cfc/getMembers.cfc?wsdl"
    method="getMembersByState"
    returnvariable="rsGetMembers">
    <cfinvokeargument name="state" value="al"/>
</cfinvoke>

I just ran this code from my system and I did not get an error, I got an
empty query.  I think your web service is working correctly.  I suspect
you are having difficulty consuming it do to caching issues.

When CF consumes a web service it create a stub that maps the web
service and it's functions.  If the profile of the web service is
changed, this stub needs to be refreshed.

Go to the Web Services section of the CF administrator under the Data &
Services section.  Delete any Active ColdFusion Web Services that refers
to this web service url.  That should force CF to refresh the stub the
next time the service is called.
Chris Luksha - 28 Sep 2006 15:46 GMT
Is there a way to force this w/o access to the server?  I can ask
crystaltech to do it for me but I don't have a dedicated server - yet so
I can't do it myslef.

> <cfinvoke webservice="http://www.femsa.org/cfc/getMembers.cfc?wsdl"
>     method="getMembersByState"
[quoted text clipped - 14 lines]
> to this web service url.  That should force CF to refresh the stub the
> next time the service is called.

Signature

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

Ian Skinner - 28 Sep 2006 15:55 GMT
Is there a way to force this w/o access to the server?  I can ask
crystaltech to do it for me but I don't have a dedicated server - yet so
I can't do it myslef.

I think there is an undocumented feature to do this through the service
factory, but I don't know the details.

You can also create a new "web service" by changing the url profile of
the service.  Change some part of this string
"http://www.femsa.org/cfc/getMembers.cfc?wsdl" and you have a
"different" web service.  I.E. if you change your webservice to
getMembers2.cfc would be a new web service.
Chris Luksha - 28 Sep 2006 16:01 GMT
Hi Ian,

Well I simply asked CT to do it and they did so.  So now I simply get
 Web service operation "getMembersByState" with parameters {STATE=al}
could not be found.

The page I am running it from is this ...

http://firegrantdata.com/consumefemsa.cfm?state=al

I used the argumentcollection="#URL#" instead of the cfarguments at this
time.

Chris

> Is there a way to force this w/o access to the server?  I can ask
> crystaltech to do it for me but I don't have a dedicated server - yet so
[quoted text clipped - 8 lines]
> "different" web service.  I.E. if you change your webservice to
> getMembers2.cfc would be a new web service.

Signature

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

Ian Skinner - 28 Sep 2006 16:09 GMT
<cfinvoke webservice="http://www.femsa.org/cfc/getMembers.cfc?wsdl"
    method="getMembersByState"
    returnvariable="rsGetMembers">
    <cfinvokeargument name="state" value="#url.state#"/>
</cfinvoke>

<cfinvoke webservice="http://www.femsa.org/cfc/getMembers.cfc?wsdl"
    method="getMembersByState" argumentcollection="#URL#"
    returnvariable="rsGetMembers">
</cfinvoke>

Well both of these worked for me, I now have a query of all your IL members.
Chris Luksha - 28 Sep 2006 16:08 GMT
Ok it finally works... http://firegrantdata.com/consumefemsa.cfm?state=il

will get me the data.  Thank you all for the great help.  Sorry if I was
being so ignorant the whole time.  as it turns out Ian - thank you - AL
returned a blank page simply b/c there was no data to return.  Duh!

Thanks Tim as well.  I never really knew how to test the cfc directly -
correctly.  Now I do.

Thanks so much guys for your patience.  (groveling :)  Now to embed that
in my brain so I can learn something else this afternoon.

Chris

> Chris,
>
[quoted text clipped - 41 lines]
>
>   -Tim

Signature

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

Chris Luksha - 28 Sep 2006 16:46 GMT
Interestingly enough - if you use  argumentcollection="#URL#" and you
have too many arguments - it throws an error.  So I must use <cfargument
and only pass on argument.

too bad - it would seem to be easier to pass all the urls vars and let
the cfc sort them out.  But hey - less server tug this way I guess.

Chris

> 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
[quoted text clipped - 58 lines]
> Thanks so much.
> Chris

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.