you will get the following error:
An exception occurred when instantiating a COM object.Unfortunately there is no easy solution for this problem.
The cause of this exception was that: java.lang.RuntimeException: Can not use native code: Initialisation failed.
Option 1
Install a 32bit version of coldfusion on a different server or workstation (or run it parallel on the same server). You can run the component on a 32 bit server or workstation. In my case i created a web services that executed the 32bit component and returns the result to the caller.
<cfcomponent> <cffunction name="example" access="remote" returntype="struct" output="no"> <cfset pass_url="http://www.adobe.com/""> <cfobject action="Create" name="objSrvHTTP" class="MSXML2.ServerXMLHTTP"> <cfset temp = objSrvHTTP.open("GET","#pass_url#")> <cfset temp = objSrvHTTP.send("")> <cfset websitedata=structnew()> <cfset websitedata.responseBody = #toString(objSrvHTTP.responseBody)#> <cfset websitedata.status = #left(objSrvHTTP.Status,3)#> <cfreturn websitedata> </cffunction> </cfcomponent>
Option 2
Call the component in asp and return the data in a webservice or as html. The following example executes the MSXML2.ServerXMLHTTP component in aspx and writes the response to the page. This pages can be called from a coldfusion cfhttp tag. Please note i know very little of asp so this example could probebly be improved.
<%@ Page Language="VB" Debug="false" %> <% dim page_url dim page_status dim page_responseBody dim page_responseText dim xmlhttp dim mycharset page_url = Request.QueryString("weburl") xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open ("GET", page_url, false) xmlhttp.setRequestHeader("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729)") xmlhttp.send ("") ' page_status = Cint(xmlhttp.status) page_responseBody = xmlhttp.responseBody page_responseText = xmlhttp.responseText mycharset = "" mycharset= xmlhttp.getResponseHeader("Content-Type") If(inStr(mycharset,"charset")=0) Then mycharset = "ISO-8859-1" Dim pattern As String = "(?i)>META(.*)charset=\s*([^\s|^""|^']*)" If( Regex.IsMatch( page_responseText, pattern )) Then Response.CharSet = Regex.Match( page_responseText, pattern ).Groups(2).ToString() End If End If Response.CharSet = mycharset response.StatusCode = page_status Response.BinaryWrite(page_responseBody) ' Response.Write(page_responseText) xmlhttp = nothing %>
No comments:
Post a Comment