Tuesday, May 22, 2012

Cross Domain Resource Sharing

There are lots of ways to do cross domain resource sharing.  Here are the 2 most popular.

  • Requires the server to "wrap" the json in a function call.

  • Better security
  • More modern
  • Requires an Access-Control-Allow-Origin string in the response header from the server.

Proxy / Server Wrapper
  • If you want to set up a proxy, go ahead
  • Or you can create your own REST service which in turn calls the resource you want.

Monday, May 21, 2012

Maven WAS RSA Dynamic Web Project Issue!

I was getting a 403 when trying to access my Dynamic Web Project in RSA.

I tried to add myself using the WebSphere Admin Console to the user mapping, but I was getting this error.

java.util.zip.ZipException: duplicate entry: META-INF/maven/com.ibm.mskhouse/DAO_MASK01/pom.xml

I took a step back and looked at application.xml from my WAS7 Test env.  It had a different security-role id, so I made it the same as the known good version and Voila!  The 403 is gone.

I also found that "Minimize application files copied to the server" is a good option to uncheck so that you can see all the files WAS is using for the hot deploy.

Thursday, May 17, 2012

Caching Service Requests

This guy is awesome: http://odino.org/rest-better-http-cache/.  I especially like the part where he's like, Application Cache?  WTF?  I worked on an application that had a really good built in application cache, but it does make you wonder why we always try to reinvent the wheel.

Friday, May 11, 2012

Oh Baby Oh How my Business did Grow - dojo.DeferredList

Oh baby oh!

Wow, so I was about to develop a REST service that gives me json for a drop down list.  But I have 4 lists coming from 4 database tables.  I was debating with myself... should I make 1 service or 4?  I need other data too.  Maybe I should lump it all together in one big web service?  Then I was thinking of reuse... that service is not very reusable.  If I made a service for each list, I could use them in other situations.  OK cool.  Then I start thinking of the code.  In one app I made in the past, I chained the REST calls and even made an object that would handle the chaining and callbacks for me.  Looking back, that was a big mistake.  Why?

dojo.DeferredList, that's why.

I did a quick google search for dojo chain xhrget requests.  DeferredList is the 3rd hit.  So it turns out that instead of calling 4 REST services in series, you can call them in parallel!  Dude if I'm late to the party, sorry, but this just blew my mind.  In other words, if the services take 400 ms, 300 ms, 500 ms and 200 ms to execute when called by themselves, instead of chaining them together and waiting 1.4 seconds, you get the results in 500ms.  Beautiful!