How to create and use web services in ColdFusion

347 Views Asked by At

I tried creating a web service in ColdFusion, for that I just created a component with a function inside it having access="remote"

<cfcomponent displayname="testPost" hint="testing.." output="yes">
    <cfsetting enablecfoutputonly="true" showdebugoutput="true">
    <cffunction access="remote" output="true" name="testPostReq" displayname="testPostReq" description="testing" returntype="any"> 
        <cfset p=9>
        <cfreturn p>    
    </cffunction>   
</cfcomponent>

Now I wanted to call this webservice and I am trying to hit this in my browser, https://sampleapp.xyz.com/DirectoryToCfc/CfcName.cfc?wsdl but in browser I am getting "Unsupported Operation. Check application log for more details." when I checked application logs I saw this log there:

"Warning","ajp-bio-8013-exec-4","09/27/21","12:57:55","COMPONENTUTILS","To use Component Browser, enable RDS Service using Administrator. Note: RDS is intended for development use only."

How can I deal with this, any idea? Is it possible to do without enabling RDS? Please let me know if you know something about this, I will be really grateful.

1

There are 1 best solutions below

0
Kannan.P On

You can create a webservice for WSDL. Here I'm going to taken an some real time demo url http://www.dneonline.com/calculator.asmx?wsdl & Coldfusion 2018. Please follow the below steps.

Step 1 : Create webservice in CFAdmin - > Data & Service - > Webservices

Step 2 : Give the Webservice name & WSDL URL value. Refer my image here (TestService.png) I've created 'TestService' for the url http://www.dneonline.com/calculator.asmx?wsdl. enter image description here

Step 3 : Once you added it successfully. You can able to see that in "Active Coldfusion WebService Options"

Step 4 : With the help of createObject method & webservice value you can call your all methods in your WSDL url. For example,

<cfset myObj = createObject('webservice','TestService')>
<cfdump var='#myObj#' abort="true">

Step 5 : You can see my below dump about demo webservice url Methods & Classes. Refer image dumpService.png enter image description here I hope this will help you to know about simple Webservice.