Thanks you all.  I got it.  Here it is, and it is verrrry cooool!

Create this cfc on one machine with database access.  
The output="No" is important.
The access="remote" is important.
The returntype="query" is important
Save it as Vendors.cfc

<!--- Vendors.cfc --->
<cfcomponent displayname="Vendors" 
   hint="Obtains all Vendor for the Purchasing Application" 
   output="No">

!--- Remote Functions --->
<cffunction 
    access="remote" 
    name="GetVendor_Remote" 
    output="no" 
    returntype="query" 
    displayname="GetVendor_Remote" 
    hint="Calls dbo.usp_VENDOR_Select_xxx">

    <cfargument name="getType" default="ALL" type="String" required="yes">
    <cfargument name="Vendor_ID" default="0" type="Numeric" required="no">


    <cfswitch expression="#arguments.getType#">
        <cfcase value = "SINGLE">
            <cfstoredproc procedure="usp_VENDOR_Select"
                datasource="#application.datasource#" 
                returncode="No"  >

                <cfprocparam dbvarname="Vendor_ID" type="In" 
                    cfsqltype="CF_SQL_INTEGER" 
                    value="#arguments.Vendor_ID#" />
            
                <cfprocresult name="qVendors">
            </cfstoredproc>
        </cfcase>
        <cfdefaultcase>
            <cfstoredproc procedure="usp_VENDOR_Select_All"
                datasource="#application.datasource#" returncode="No"  >
                <cfprocresult name="qVendors">
            </cfstoredproc>
        </cfdefaultcase>
    </cfswitch>
    <cfreturn qVendors>
</cffunction>
</cfcomponent>

Create this cfm page on ONE OR MORE webservers!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
        <title>Untitled</title>
</head>
<body>
<cfinvoke
    webservice="http://localhost/Purchasing/Vendor.cfc?wsdl";
    method="GetVendor_Remote"
    refreshwsdl="true"
    returnvariable="qVendor">

    <cfinvokeargument name="getType" value="SINGLE">
    <cfinvokeargument name="Vendor_ID" value="40">
</cfinvoke>

<cfdump expand="Yes" var="#qVendor#" />
</body>
</html>

Notes:
1. Taging the function as access="remote" publishes it as a web service.
2. Taging the invoke with webservice attribute consumes the webservice.
3. CF take care of handling all the json or xml protocols between the two 
servers.
4. You can also see the results as <wddxPacket> (xml) directly in your browser
http://localhost/Purchasing/Vendor.cfc?method=GetVendor_Remote 
5. Pass parameters on the command line
http://localhost/Purchasing/Vendor.cfc?method=GetVendor_Remote&getType=SINGLE&Vendor_ID=44
6. Needless to say you can do any type of processing in the cfc, not just query 
data.

Nick Stein




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300758
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to