Call the ColdFusion function on another server?

I have a Java class that I have to run, my current host (shared) will not allow Java. I need to host it on another server. I was told that I cannot call Java from ColdFusion on a separate server, but what if I call the CF function on the second server, then this function will call the Java class, return the data to CF, then this function will return to the original? Sorry if this sounds kludgy, but I can't think of any other solutions.

Is anyone Ideas?

+6
java coldfusion
source share
2 answers

If you have access to a server where you can run Java, can you even run all this?

Otherwise, as you understand, you can simply create a component with a remote function and perform this work in accordance with:

<cfcomponent output="false"> <cffunction name="runMyJava" returntype="String" output="false" access="remote"> <cfargument name="MyArg" type="String" /> <cfset var MyObj = createObject('java','whatever') /> <cfreturn MyObj.doJavaMagic( Arguments.MyArg ) /> </cffunction> </cfcomponent> 


Then on your other server you will have something like ...

 <cfset MyWebService = createObject('webservice','https://myotherserver/mycomponent.cfc?wsdl')/> <cfset MyString = MyWebService.runMyJava( MyString ) /> 


Please note that https is used in this example - because you presumably want to protect data from spanning over the Internet in plain text.

It may also be wise to restrict the IP server to a server, so you can connect to it or use other appropriate methods to protect it.

+12
source share

I would install a web service using coldfusion on your second server to call the java class, and then just have a website on your web site use this web service.

+4
source share

All Articles