• Home
  • About George
  • Contact Me
Blue Orange Green Pink Purple

Posts Tagged ‘web service’

You can use the search form below to go through the content and find a specific post or page:

Aug 05

Guest Post: structDeleteAt() doesn’t play nice with webservice returns

Sooner or later, we all experience it.  The chill runs down our spines, and we stare at the computer screen, not knowing whether to cry or curse at the cryptic error that rears its ugly head and laughs at us.

What I’m referring to is, of course, coldFusion deciding that it only wants to do things a certain way, regardless of how you *think* the process should go.

Not too long in the distant past, I encountered such a beast, and will relate my story now.

The task was simple:  connect to a webservice, and display the results.  As the project progressed, the rules changed slightly – now I needed to grab the results, and filter out any that didn’t belong based upon a criterion set.  Never you mind that usually, the web service would be changed or manipulated so that a parameter or two could be passed in & perform the filtering on the server side.  That wasn’t a possibility in this case, and wouldn’t prove to have been near as much fun.

The rumblings and mutterings from the nether world began when I attempted to loop over the results and filter out any which didn’t fall within the specified criteria.  Normally, this would just involve a cfif tag to test each set of returned data to decide to display it or not.  The crux of the problem was that before entering the loop, the count of how many records were returned was displayed.  Depending on how many records were excluded, this count could be, and was, way off of the actual records that were displayed.

My initial theory was to loop over the record set returned from the webservice, and use a structDeleteAt() call to remove any records which did not match what I was trying to display.

*KABOOM*

ColdFusion refused to delete the record.  I tried everything.  Setting the value to empty, using a Javacast to set it to null, even copying the returned result set, and working with the copy.

None of it worked.

ColdFusion liked how the returned result tasted, and wasn’t about to let go, not for any amount of cajoling or cursing at it.

Finally, defeated, I tried a different approach.  Instead of using any trickery, or established CF functions or methods, I decided to bring a howitzer to this knife fight.

The answer lies in the code below.

<cfloop from="#ArrayLen(serviceReturn.contacts.anyType)#" to="1" step="-1" index="i">
<cfset tmp = serviceReturn.contacts.anyType[i] />
<cfset tmpPaidThrough = tmp.getPaidThrough() />
<cfif EXPRESSION_TO_CHECK_AGAINST >
<cfset tmpInsert = arrayappend(session.searchResults,serviceReturn.contacts.anyType[i]) />
</cfif>
</cfloop>

To explain:

  • loop over the record set returned by the webservice.
  • set the record to a temp variable, and get the part that we want to check against (in this case, paidThrough)
  • if the record passes the test, append it to a new variable (session.searchResults)
  • note that I have gone from the end of the struct to the beginning, but I believe it would work either way

Then, in the display portion of the code, instead of using the returned record set, we use the new variable we set up that only has the records in it that have passed the test for display purposes.

*VOILA*

ColdFusion, realizing that it has been defeated, slinks off to haunt some other poor soul.

I’m not entirely sure why CF would not relinquish the record of the returned set.  In discussion with other developers, we reasoned that perhaps since the return was a struct of struct of structs, somewhere in the vast underlying java mysteries, the pointers could not be moved or deleted, so CF did not want to delete the data.  Copying the returned structure resulted in a structure of the same design, so CF wasn’t able to delete from a copy any more than it could from the original record set.

So there you have it.  Wipe the blood off your sword, hoist a beer, and move on to another realm, full of it’s share of demons and battles.

-Dave

Apr 07

Web Service Run Around

I was recently tasked by my bosses to make some changes to a web service that existed on one of our clients sites. I’m not an ASP.NET guy – but it turned out to be what it was currently written in so I wanted to give it a shot and figured it would save me time on actually getting it done. That should have been my first clue that I was way off!

So I started off by having to upgrade the .NET library – the old app was written on version 1 something of .NET and the free Visual Web Developer forced it into an upgrade in order for me to even look at the code. I had tried using Eclipse first but that just have any way to compile out the ASP code. So after upgrading, we went through some hoops getting the server upgraded and also one crash of the IIS Server by not setting the DefaultAppPool properly. Like I said – not an ASP.NET guy!

So after that’s all compartmentalized, we start running into 401 – User Not Authorized problems. Turns out we had the server set to accept client certificates and were unable to connect through with them. Got that changed over and both the old service and the new seemed to be accepting the login scheme I copied over without a problem. When I went to run my new functionality though I just couldn’t get it to work. So I changed the name of my .asmx file from the default Service1 to NewService and went through the associated hoops trying to get everything running and compiling again. That was fun in and of itself. After uploading it, I could no longer connect when pointing to NewService. It seems that even though Service1 was in a different directory and application for ASP.NET when I was calling them – the SOAP URLs were pointing to the right places – that my calls to the app that now had NewService had been calling the Old Service1 instead.

So again I ran into the 401 Unauthorized problems. Started digging some more and there were a couple of things that I was able to finally find after much reading on the Internet. It seems that most suggest using anonymous browsing for the web service application directory. We couldn’t do that because of security requirements on the project, so we had it set to Integrated Windows Authentication under the Directory Security tab. However ColdFusion wasn’t able to talk to it then. Once I added Basic Authentication and gave it the proper domain, I was then able to connect like a champ and hit the newly created service!

So don’t forget to make sure your IIS Settings are what they should be, and then add to that the name changes. Now I just need to figure out how to create a test environment for this so that I can compile and make changes without taking down the service for the clients while they are working!

Web Development By George

  • Pages
    • About George
    • Contact Me
  • Tags
    Access Ajax asp.net ColdFusion coldspring cross browser CSS Databases Design errors firefox Flash Flex html ie7 JavaScript Merge Model-Glue PCI Compliance Personal server monitor split function Subclipse Subversion tab tabview web service YUI
  • Archives
    • February 2010
    • January 2010
    • November 2009
    • October 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
  • Search




Add to Technorati Favorites

Bad taste download movie A dog s breakfast download movie Entropy download movie Away we go download movie Once upon a time in mexico download movie Moon 44 download movie The escapist download movie Clubbed download movie Illegal Aliens download movie I Think I Love My Wife download movie I Capture the Castle download movie Hoodwinked! download movie Hatchet download movie Ghetto download movie Fantasia/2000 download movie F/X download movie Everything You Always Wanted to Know About Sex * But Were Afraid to Ask download movie Donkey Xote download movie Day of Wrath download movie Bad taste download movie A dog s breakfast download movie Entropy download movie Away we go download movie Once upon a time in mexico download movie Moon 44 download movie The escapist download movie Clubbed download movie
  • Home
  • About George
  • Contact Me

© Copyright Web Development By George. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top