Java – call the ColdFusion function on another server?

I have a Java class that must be run, and my current web host (share) will not allow Java I need to host it on another server I was told that I can't call Java from ColdFusion on a separate server, but if I call the CF function on the second server, then let the function call the Java class, return the data to CF, and then return the function to the original? Sorry, if this sounds lame, but I can't think of any other solution

anybody? Ideas?

Solution

If you have access to a server that can run Java, can you run the whole thing there?

Otherwise, as you want, you can create a component with remote functionality and complete the work as follows:

<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 servers, you will have

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

<cfset MyString = MyWebService.runMyJava( MyString ) />

Please note that this example uses HTTPS – because you may want to protect data from spreading over the Internet in plain text

IP restriction server is also wise, so only you can connect to it or use other appropriate methods to protect it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>