Cannot add the most basic RESTful web service - web-services

I'm on Windows 2008 R2 (64-bit) using CF10 (64-bit) (developer edition?)
I am trying to implement this very basic tutorial:
http://blogs.coldfusion.com/post.cfm/rest-support-in-coldfusion-part-i
I created a new website through IIS on port 8081 and then added two files:
/index.cfm (in theory, since no application.cfc containing app vars was needed, I could have skipped this)
<cfset s = "Hello World!">
<cfoutput>#s#</cfoutput>
/RestExample/HelloWorld.cfc
<cfcomponent rest="true" restPath="/hello">
<cffunction name="sayHello" access="remote" returnType="String" httpMethod="GET">
<cfset res="Hello World">
<cfreturn res>
</cffunction>
</cfcomponent>
In CF Admin:
Root Path: C:/websites/test/RestExample/
Service Mapping: Example
I get the following error:
Error registering REST service. Please ensure that you have entered a proper mapping and path.
Application Example could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs.
A bit of system information:
Server Product ColdFusion
Version 10,0,8,284032
Tomcat Version 7.0.23.0
Edition Developer
Serial Number Developer
Operating System Windows Server 2008 R2
OS Version 6.1
Update Level /C:/ColdFusion10/cfusion/lib/updates/chf10000008.jar
Adobe Driver Version 4.1 (Build 0001)
JVM Details
Java Version 1.6.0_29
Java Vendor Sun Microsystems Inc.
Java Vendor URL http://java.sun.com/
Java Home C:\ColdFusion10\jre
Not sure if it's a configuration issue at this point? This is related to my previous question, and trying to simplify everything to isolate the cause.
Edit #1
I was able to add a this very simple RESTful service to a Windows 7 64-bit / CF 10 (no updates) without any issues. I wonder if it's my install that is corrupt or the update that corrupted it?
Edit #2
I reinstalled my CF server and it still gave me the same issue.
Edit #3
As per milanchandna's suggestions, I followed these steps:
Created a folder c:\websites\milanchandna
Created a new website (milanchandna using the apppool with the same name) in IIS and used c:\websites\milanchandna as root, running on port 8084
Created jakarta virtual directory (need this)
Added basic HelloWorld.cfc
Navigated to HelloWorld.cfc with success, no errors
In CF Admin, REST Services, added the following:
Root Path: C:/websites/milanchandna/
Service mapping: Example
Click Add Service
Get error:
Error registering REST service. Please ensure that you have entered a proper mapping and path.
Application Example could not be initialized.
Reason: The application does not contain any rest enabled CFCs.
The application does not contain any rest enabled CFCs.
HelloWorld.cfc:
<cfcomponent rest="true" restPath="/hello">
<cffunction name="sayHello" access="remote" returnType="String" httpMethod="GET">
<cfset res="Hello World">
<cfreturn res>
</cffunction>
</cfcomponent>

I created the files under C:\ColdFusion10\cfusion\wwwroot (instead of the site's IIS root) and was able to register the REST service via the administration console without any issue.

As this is a basic example not working, I will suggest to follow it from starting.
Create a fresh new folder in IIS webroot. This should not be inside any folder already being used for CF REST.
Just put one simple rest cfc in this folder and nothing else. The CFC example given in your problem description looks good, let's use that.
Access this CFC from browser as you would access any cfm
eg:[http://mysite:8081/mypath_to_cfc/mycfc.cfc]
Check if this throws any error. If it does, then there is a problem in CFC. If it doesn't then you are good to go.
Register this folder as REST application from administrator.

Related

How to create and use web services in ColdFusion

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.
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.
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
I hope this will help you to know about simple Webservice.

Not able to a https web service in ColdFusion 8

We are trying to add a https web service via CFadmin in ColdFusion 8.
We have two ColdFusion applications. One on ColdFusion 2016 and other in ColdFusion 8.
The CF8 application consumes few of the Web services of CF2016 application.
Recently, we added SSL to CF2016 application. So now the URLs of this application are HTTPS.
After it, few of the modules of cf8 that were consuming the webservices of cf2016 stopped working.
We figured it out that we need to update the webservice urls in cf8 with https urls.
We tried to update the webservice urls in CFAdmin but with no success. ColdFusion doesnot allow us to do it. It shows one error message
Error creating web service. Please ensure that you have entered a correct Web Service name or URL.
We have checked the WS url in browser. It's returning the WSDL XML.
After a bit of searching we found this link
http://www.richarddavies.us/archives/2006/02/enabling_web_services.php
It suggests to add the SSL certificate to ColdFusion's Java Keystore and restart ColFusion services. We followed the steps - Imported the SSL certificate to keystore and restarted coldfusion service. But no success. We also tried restarting the whole server.
Can some suggest what else needs to be done to add HTTPS webservice to ColdFusion 8. We are currently clueless.
Configuration:
App1(non ssl) - CF8-multiserver, java6,iis7.5, windows server 2008 r2
App2(SSL installed) - CF2016, java8, iis8.5, windows server 2012 R2
The quickest solution you can do is to upgrade the CF8 to cf2016.
If Windows 2003 Server as there is no support from Microsoft for TLS 1.1 or 1.2 in this server version.
https://blogs.msdn.microsoft.com/kaushal/2011/10/02/support-for-ssltls-protocols-on-windows/

ColdFusion CFDump Web service

I'm in the process of migrating our web applications from a Cold Fusion 9 server to a Cold Fusion 2016 server and one of the web service calls that works perfectly in CF9 is now raising the following error in CF2016.
Web service operation InsertBank with parameters
{2,JOHNSON,BRIAN,450,450100530,21/02/2017,C,11212,006,128661543321,A,en}
cannot be found.
I'm calling the method directly through CFScript (I've already defined the web service using createObject(), and assigned it to an application variable for easy use)
result = Application.AdminWS.InsertBank(Trim(Application.ApplicationId),Trim(uname),Trim(Session.Employee.Client.xmlText),Trim(Session.Employee.Certificate.xmlText),Trim(DateFormat(Now(),"dd/mm/yyyy")),"C",Trim(instiNum),Trim(accouNum),Trim(transNum),Trim(varAccStatus),session.language);
I'm aware that Axis2 was introduced in CF10 however in ColdFusion Administrator I set the default as Axis1; I don't believe this is the cause of the issue. I've tried refreshing the WSDL however the only difference between the WSDL files between the two servers are the URLs.
Is there a way to cfdump a web service and view all of it's parameters?

Error registering REST service in ColdFusion 10

I'm having a problem registering a REST web service in the ColdFusion Administrator. I'm using ColdFusion 10 on a Windows server, and the error I get after trying to register a REST web service is:
Error registering REST service. Please ensure that you have entered a proper mapping and path.
Application CA could not be initialized.
Reason: class "com.sun.xml.bind.Util"'s signer information does not match signer information of other classes in the same package
class "com.sun.xml.bind.Util"'s signer information does not match signer information of other classes in the same package
I've tried registering a service on both a remote CF instance as well as my local instance. Locally I've tried just a real basic service - basically one CFC in an application all by itself, but still get the error. I am putting in both the Root path and the Service Mapping, as I do not have an Application.cfc in the application.
Any ideas?
This problem was caused by some custom JARs I was referencing in the ColdFusion Class Path in the Java and JVM settings in the CF Admin utility. I removed the references to the JARs and restarted the CF instance. Then I was able to successfully add the REST WS. I then re-added the JARs in the class path and restarted the instance. The proper solution is probably to recompile those JARs with the same certificate, but if you don't have access to the source code, this may be the only workaround.

Coldfusion web service problem solving

On CF 9.01, Windows Web Server 2008 R2, a web service has stopped running here, so I'm trying to figure out the problem. I think the problem may have started when I applied the 9.01 hotfix.
I added a test.cfc to the server
<cfcomponent output="false">
<cffunction
name = "echoString"
output = "no"
access = "remote" returntype="any">
<cfargument required="true" name="inputString" type="string"/>
<cfreturn arguments.inputString>
</cffunction>
</cfcomponent>
and call it with
<cfinvoke webservice="https://nww.somedomain.nhs.uk/cfcs/test.cfc?wsdl"
method="echoString" returnvariable="returnedString">
<cfinvokeargument name="inputString" value="test string 2">
</cfinvoke>
and get the string response, but in the cf administrator the web service is not being added
when I invoke the web service for the first time as I think it should be.
Other than reinstalling CF or trying to roll back manually, any clues as to the problem or how I can test please?
I'm on 9,0,1,274733 . The https is not the problem I think. Firstly it was working fine then with no change to code it stopped. Secondly my test invocation of test.cfc works as expected over https.
If I hit https://nww.somedomain.nhs.uk/cfcs/test.cfc?wsdl (which works) or my problem cfc https://nww.somedomain.nhs.uk/cfcs/providerapi.cfc?wsdl directly in the browser they both correctly show the XML details.
However, invoking either of the CFCs does not add them to the active web services list in administrator.
I pasted the "echostring" method to my problem CFC (providerapi.cfc) and tried calling the method but I get a "webservice cannot be found" error. It's like the providerapi.cfc is cached , but I can't see it in administrator to delete it.
I tried this verbatim on 9,0,1,274733 and it worked 100% fine. I am using Win 7 and I just tried it on my dev environment. The web service was added to the list in CF admin so you are correct to expect that.
Can you ensure that you can hit the URL direct (i.e. https://nww.somedomain.nhs.uk/cfcs/test.cfc?wsdl) in your browser and view source to see the WSDL XML?
One thing that jumps out is the use of https:// in your web service invocation. Can you try it with just http:// or even better against your localhost?