ColdFusion WS Consumer for a WS Created in VS2003 - The Consumer using ColdFusion
(Page 3 of 4 )
ColdFusion has two ways to create clients that consume web services. The first method creates a webservice object, and through it the methods are invoked by discovering the service description. This is the method that will be used for this example. In the next example, the tag based syntax directly calls the web service by sending arguments to it.
Step 6: Now create a file called CFFindJay.cfm and code as shown below. The client browses the file CFFindJay.cfm to access the service. The code follows:
<cfscript>
ws = CreateObject("webservice",
"http://localhost/FindJay/Service1.asmx?WSDL");
fndstrg = ws.FindJay();
</cfscript>
#fndstrg#
CreateObject() creates a ColdFusion Component (CFC) and the calling syntax is:
CreateObject (type, component-name)Hence the variable ws in the code above creates a "webservice" type of object, and the WSDL is the component-name. As mentioned earlier, the component-name is the URL with “? WSDL” appended to it. To invoke the components' methods, you call the functions in the component, in this case FindJay (). We know beforehand that the method returns a string; therefore we will be looking for a string and display it like any other function.
Step 7: Place the CFM file in the appropriate folder on your server (it is assumed that ColdFusion has been installed as discussed in the introduction). Now if you browse this folder you will see the following in the display.

Next: Second Example >>
More ASP.NET Articles
More By Jayaram Krishnaswamy