ColdFusion WSDL times out on first call - web-services

I have a web service setup for on a small part of a website and while the site overall gets a good amount of traffic this particular service does not. Once a day when I go to send a request through the web service it will fail on the first attempt, but retrying the request a second time works just fine. It's as if it was no longer cached in memory and times out while starting up.
Is there a way to keep this service active either on my end or on the web service provider's end which is also CF app (separate division of our company)? It's a bit hard to troubleshoot because it only happens once after a long period. And I don't want to setup a separate process just to keep pinging this service.

If the server is being restarted regularly between calls to the template, ensure the "save class files" setting is enabled in the administrator (under caching) to prevent the template from being recompiled after each server reload.

You can try to use following method on a webservice client side.
CF7+ got built-in coldfusion.server.ServiceFactory Java service.
Code can look like
<cftry>
<!--- here goes attempt to invoke service method, maybe dummy "ping" --->
<cfcatch type="any">
<!--- trying to refresh WSDL --->
<cfset createObject("java","coldfusion.server.ServiceFactory").XmlRpcService.refreshWebService(ServiceURL) />
</cfcatch>
</cftry>
<!--- usual code --->
Hope this helps.
Note: this factory contains a lot of useful methods, but almost zero documentation over the internet. Good idea would be to dump it and explore a bit.

Try increasing the requesttimeout and see if that helps.

Related

Cold Fusion 11: Variable is Undefined in session

Recently some users have been experiencing this error. This error doesn't appear until the user is in the application for a bit (Ranged from a couple minutes to hour and a half).
When this issue first came up, I modified the application.cfm file which contains the timeout variables. This helped one user, but now more are experiencing the same error. Below is the modified code, I exended the timeout to 200 minutes.
<CFAPPLICATION
NAME="MyApplication"
SESSIONMANAGEMENT="Yes"
sessiontimeout="#CreateTimeSpan(0,0,200,0)#"
applicationtimeout="#CreateTimeSpan(0,0,200,0)#">
My question: Users are still experiencing this timeout error within 5 minutes, after I set the timeout to 200 minutes. Can there be a variable or something that is set on the CF Admin side which overrides my timeout span? If there is not, I will need to research into this more. Any suggestions or comments are helpful, thanks.
You definitely need more info from the hosting provider. Common issues include:
They are load balancing and not using sticky sessions. So the user will have to login and create a session on each server that is part of the loadbalanced cluster.
They have a proxy or webserver in front of the ColdFusion server with configuration that alters the response from the ColdFusion server.
They have settings in the CFAdmin console that limit the application settings, as per the comments provided by TRose and Chris.
So the concern is timing out: IIS, Apache, and TomCat web services can timeout as well. For example if Apache is set to timeout in 300 seconds but Coldfusion is set to timeout in 350 the web service will always trigger beforehand (it won't matter what you do in Coldfusion Admin or Cfsettings because the web server supersedes it).
So web server timeout implementations could front run your Coldfusion to timeouts.

Should I use CFTHREAD to slow down bot traffic?

We recently migrated our site from application.CFM to application.CFC. The CFM version could handle our excessive bot traffic, but our CFC version can't. We are trying to figure out why the CFC problem is. In the meantime, we are trying to limit bot traffic.
Currently, I am looking for a solution within the code base to slow bot traffic. We can do this by looking at the user agent as well as IP address.
We have used the code below to successfully stop many bots.
<cffunction name="OnRequestStart">
<cfif find("bot", cgi.httP_USER_AGENT)>
<cfabort>
</cfif>
</cffunction>
Obviously, we do want some bot traffic. But right now, we can't handle all of the bot traffic. It appears that as soon as we you abort to stop a request, another request is right behind it and eventually they bring down our server.
Instead of stopping the bots, what would the ramifications be of using CFTHREAD to slow the bots?
<cffunction name="OnRequestStart">
<cfif find("bot", cgi.httP_USER_AGENT)>
<cfthread action="sleep" duration="5"></cfthread>
</cfif>
</cffunction>
Would using CFTHREAD just stack up the requests and eventually kill our server or would the bots respond with fewer requests per hour?

Coldfusion 9 cfexchangecalendar exchange server outlook 2007

CF9
Exchange server 2007 (hosted)
I am trying to add a calendar event for a user on our hosted exchange server. I'm getting the error ;
Unable to connect to the Exchange server using HTTP/HTTPS protocol.
HTTP response code : 400
The code is;
<cfexchangeCalendar action="Create"
username="EXCH016\ron_domain"
password="password"
mailboxname="ron"
server="https://owa016.msoutlookonline.net/owa"
Protocol="https"
formbasedauthentication=true
formbasedauthenticationURL="https://owa016.msoutlookonline.net/owa/auth/owaauth.dll"
Event="#sEvent#"
result="theUID">
#theUID#<br>
I know I can contact the server using the following;
<cfhttp URL='https://owa016.msoutlookonline.net/owa' result='res' >
<cfdump var="#res#">
<cfoutput>#res.filecontent#</cfoutput>
I get the form that requests email address and password.
I've been working on this problem for some time now. I can go to the owa page via browser and log in. At this point I'm at a loss on how to debug the problem.
I have had the same type of problem in the past, when one of my customers went from Privately Hosted and Run vs Hosted Solutions.
Although, I never used the formbasedauthentication method when authenticating, maybe this bypasses some of my issues.
The big thing we had issues with is that most Providers don't all WebDav access on their servers.
Since you are getting a 400, bad request, this is what I would look for first.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=cfexchange_3.html talks about what CF needs to connect to Exchange, maybe see if the support staff can confirm the setup.
Since you are using HTTPS, have you added the Cert into the JRE cert Store?
Sorry this probably isn't much help, but I hope it helps.

Sharepoint denying access to asmx methods

We have a site running on MOSS 2007 which makes calls to custom web service asmx methods on the same domain from the client.
On the live site requests are getting redirected to the following url:
http://[domain]/_layouts/error.aspx?ErrorText=Request format is unrecognized for URL unexpectedly ending in %27%2FIsSuspectWaterLevel%27.
We've added the following to the sites web.config without any joy:
<system.web>
<webServices>
<protocols>
<add name="HttpSoap" />
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
...
</system.web>
Interestingly enough we don't have this issue on the test server which is supposed to be pretty identical to the live server.
Any ideas to what other variable might be at play here?
Thanks in advance for any ideas,
Gavin
Update:
While a call to
http://[Domain]/_vti_bin/Custom/CustomFunctionality.asmx/IsSuspectWaterLevel
fails, I can still access
http://[Domain]/_vti_bin/Custom/CustomFunctionality.asmx?op=IsSuspectWaterLevel
though it fails when I invoke the method in the same way.
I wonder if this helps shed more light on the issue?
Another Update:
I've just observed the same error on the dev server. Removing the apps dll from GAC and then re-copying it in solved the issue. The live server tested fine with initial deployment so perhaps there's an issue with Sharepoint loosing some reference over time? Clutching at straws as very confusing behaviour!
Yet Another Update:
It seems everytime I touch (open and save) the web.config file in 12 Hives the problem is fixed again for a period, but after a while the problem comes back. I wonder if it's anything to do with the app pool being recycled?
C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\ISAPI\web.config
An inelegant workaround to this issue that works for us: We've swapped out the web service asmx end point for a web handler ashx endpoint. This doesn't suffer the same issue for some reason.
I'm guessing from this that there's some issue creeping in after a period of time which is causing urls to resolve incorrectly. I suspect that the / after the .asmx in the url is the curprit. The ashx endpoint implemented is working purely on url parameters and posted data.
Obviously this work around won't always be an option for others who might experience the same issue as we're loosing a lot of the rich web service functionality that's pre-baked in to an asmx endpoint.
Unfortunately I won't be able to test any other solutions that people might put forward from now on as we've moved away from the web service asmx approach. Sorry.

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?