When I return a string from my remote method from cfc. The returned string is wrapped up in a strange wddxpacket:
I tried to turn off the debugging output like this:
<cfsetting showDebugOutput="no">
But it didn't work.
set returnformat to plain or json in the remote <cffunction>
see: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f5c.html
Related
While invoking the Webservice API for the GetTablesBin method, I'm getting the error Web service operation GetTablesBin with parameters cannot be found.
Webservice Calling code
<cfinvoke
webservice="http://www.argusmedia.com/ArgusWSVSTO/ArgusOnline.asmx?wsdl"
method="GetTablesBin"
returnvariable="binResponse">
<cfinvokeargument name="authToken" value="#AuthToken#"/>
<cfinvokeargument name="tableNames" value="#tablename#"/>
</cfinvoke>
I can see the method running fine using the SOAPUI client.
While digging further, found the method class to be missing in the Coldfusion stubs folder as well.
Any pointers would be really helpful?
Web service operation GetTablesBin with parameters
{...} cannot be found.
Notice it says "with parameters"? Subtle difference, but it either means a) the method does not exist at all OR b) it does exist, but is receiving the wrong number or type of arguments. In this case the problem is "b)".
When troubleshooting web service issues, it is often helpful to create an instance of the web service, then dump that object to see which arguments the method requires. According to CF11, the "GetTablesBin" method expects two arguments: a String and an ArrayOfString. However, the current code passes in two String's. Hence the error.
Code:
<!--- Add {refreshWSDL=false} if needed --->
<cfset ws = createObject("webservice"
, "http://www.argusmedia.com/ArgusWSVSTO/ArgusOnline.asmx?wsdl")>
<cfset writeDump(ws)>
Dump:
An ArrayOfString is a slightly strange beast:
... there is no direct mapping of ArrayOfString. So it is essentially
treated as a structure, just like any other complex type. If you look
at the wsdl, ArrayOfString contains a single key named string, whose
value is an array of type="s:string":
To resolve the error, simply create a structure with the proper key and pass it into the cfinvoke call. (Though personally I prefer createObject() which is a little less bulky IMO)
<cfset arrayOfStrings = ["tableName1","tableName2"] />
<cfset tableNames.string = arrayOfStrings />
<cfinvoke ....>
<cfinvokeargument name="authToken" value="#AuthToken#"/>
<cfinvokeargument name="tableNames" value="#tableNames#"/>
</cfinvoke>
I wrote an application at work that uses a few CFC's- I'm having some errors but I want to actually mail the errors out because the application is live and they are happening rarely.
I can't stop what's currently running to troubleshoot.
Does anyone have any experience/can point me towards doing cfmail inside of a cfc/cfscript? More specifically, inside of a try/catch within cfscript.
We're running ColdFusion 9 which doesn't support <cfmail> inside of <cfscript>.
The mail CFC is built in to CF9 and above. You can use it in cfscript and it shouldn't matter where you implement it - within a try/catch block should be fine in onError.
Adobe has an example of the usage in their documentation for CF9:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0693d5dae123bcd28f6d-7ff9.html
Write a new cfc with a function to send an email and then include that within the try/catch. Something like below will work
sendMail.cfc (missing a lot of things, but this is the structure)
<cfcomponent output="false">
<cffunction name="sendEmail">
<cfargument name="errorMessage">
<cfmail>
<cfdump var="#arguments.errorMessage#">
</cfmail>
</cffunction>
</cfcomponent>
try {
//code here
} catch (any e) {
var sendEmail = new sendMail();
sendEmail.sendEmail(e);
}
My question seems to be related to this one:
Coldfusion memcached connections
however, i have been unable to solve it.
if i put this code in application.cfm:
<cfif not IsDefined("application.memcached")>
<cfset application.memcachedFactory = createObject("component","memcachedFactory").init("192.168.2.91:11211")>
<cfset application.memcached = application.memcachedFactory.getmemcached()>
</cfif>
the page will work for maybe 270 calls. then it will start to fail with an error "Object Instantiation Exception " The code is properly talking to memcached. I can send and receive data. it seems like java is running out of something .. threads, sockets, handles of some sort. I know little about java, and am stuck.
This seems wrong to me Don. Why would this code run again after the very first call? It should be running 1 time after which you have a reference to your object. What does the rest of your application.cfm look like? Have you added a cfapplication tag with a "name"?
If you fail to set an application "name" (via the cfapplication tag or "this.name" in application.cfc), the an "application.x" variable is treated just like a regular variable. After the page request ends it will "go away" and require the next request to reinstantiate the object over again.
The purpose of the "isDefined()" in this case is to insure it runs only once - providing you with a singleton (single reference) you can use again and again without reinstantiating it. It sounds like you are not "inside" an application.
So I found some code
<cfset x509 = GetPageContext().getRequest().getAttribute("javax.servlet.request.X509Certificate") />
<cfoutput>not before = #x509[1].getNotBefore()#</cfoutput><br/>
<cfoutput>not after = #x509[1].getNotAfter()#<br></cfoutput>
<cfoutput>#ToBase64(x509[1].getEncoded())#<br></cfoutput>
<cfoutput>#x509[1].getIssuerDN()#<br></cfoutput>
<cfoutput>#x509[1].getIssuerX500Principal()#<br></cfoutput>
What I want this code to do is display the information from the CAC, instead I am getting an error Variable X509 is undefined...
Edit
An alternate solution seems to be to use CGI.CERT_SUBJECT however I am not exacly sure how to get this variable to be anything other than an empty string. FWIW I am try to get this to work on a standalone coldfusion server.
The getAttribute() method returns a NULL variable when the attribute is not found, which is what's happening in this case. You have to see if it's defined before you can display it.
<cfif StructKeyExists( variables, "x509" )>
{ Code }
</cfif>
On how to get the attribute you're after, I couldn't tell you, but this will prevent the error from occuring.
Depending on your web server (I know Apache does this if you set SSLOptions +StdEnvVars +ExportCertData), you can get the PEM-encoded cert as an environment variable (i.e., cgi.ssl_client_cert) and you can get other info (DN, issuer's DN, etc) as well. Here's a list of the environment variables.
How can I read the default application.datasource from my code?
A dump of application does not show me the datasource, and trying to read application.datasource gives an error.
Try dumping application.getApplicationSettings()
Try re-start the applciation. You can't just dump application and see the datasource. But if you have this set in application.cfc it "should" be working.
component output="false" {
this.name = "MyDemo";
this.datasource = "DemoDB";
}
Edit: Nice Tony I didn't know that.
The this scope in the Application.cfc only persists for the duration of the onApplicationStart(), onSessionStart() onRequestStart() etc.
If you want to expose variables, in your onApplicationStart(), simply store the in the application scope.
application.myVariable = myVariable;