September 2006 - Posts

Quick tip: using UserControl events as triggers
Tue, Sep 26 2006 1:34

Jus t a quick reference to an old post on the atlas forums which might help those that need to use a UserControl as a trigger.

Understanding the iframecall.axd handler
Tue, Sep 19 2006 1:44

Most guys that have been using ATLAS till now haven’t had the time (or patience) for understanding how the communication between the client and the server is handled, ie, for most guys, it just works! Though I’ve followed this path many times before, I decided to take some time and understand what’s going on when you start a remote request from the page (ie, when you use Javascript to get info from a local or remote server).

Let’s start from the beginning (ie, from the cliente side)…ATLAS’ client platform has the notion of executor: a class whose sole purpose is to call a remote site (server side of the app or remote application) and get the necessary info. Currently, the platform defines two types of executors: XMLHttpExecutor e IFrameExecutor. Both these classes extend the abstract WebRequestExecutor class.

Both executors perform the server side calls asynchronously. Btw, nothing prevents you from developing your own executor. For instance, let’s say you have a scenario where you need to perform a synchronous server call: you can’t do it with none of the predefined executors so you might build your own which could do just that. Going back to the executors, it’s fairly obvious to understand how they work by looking at their names: the first (XMLHttpExecutor) uses the XmlHttpRequest object to communicate with the server side; on the other hand, the second (IFrameExecutor) uses an iframe to get the necessary data from the server. In this post, I’ll just talk about this second executor.

In the last days, I’ve seen that there’s been an increase in the number of questions related with remote web service invocation. Looking at the docs, you may think that you’re only option is to use a bridge or build your own web service which wraps the remote call. Well, I’d say that there’s still another option, if you’re in control of the application which hosts the web service: use the IFrameExecutor to perform that remote call!

So, let’s go back to the beginning… if you’re using one of what I call “high level network” classes, most of the time the correct executor will be automatically picked up to perform a remote web method call. When the IFrameExecutor enters the game, you must configure the target remote application so that the IFrameCall.axd handler is on (by adding the necessary entry to the web.config file). This is needed because the IFrameExecutor depends on that handler to get the data in the correct format from the server. It’s important to note that IFrameHandler implements the IHttpAsyncHandler interface (indirectly) so that it can perform its work asynchronously. After getting the results from the web service, they’re packaged on a javascript object (serialized in JSON) and sent back to the client.

Well, nothing new here. What most guys haven’t got yet is that the IFrameHandler must be activated on the site that is hosting the remote web service and not in the one that has the page that is making the call. Let me give you an example. Let’s suppose that application A has a page (PA) that is trying to invoke a remote web service (WS) which is hosted at a remote web site (B). If you want to, you can invoke this remote service from the client side of page PA by using the IFrameExecutor. However, for it to work, you really need to ATLAS-enable site B and activate the iframecall.axd handler because IFrameExecutor will call that handler to get the result. Unfortunately, most guys think that they need to activate iframecall.axd in site A (which is wrong) and then end up thinking that remote services can’t be called from the client side of page.

One more note: most of the client components which perform remote calls have a property called appURL which is really important and can be used to influence the site used by the executor. The correct configuration of this property might be important in some scenarios.

So, now you know: when you’re trying to invoke a remote web service and you’re getting an iframecall.axd related error start by checking if it’s enabled on the destination site.

Though this option may not be viable in all the scenarios, I really think that if you’re in control of the remote app you should use it because by doing this you are communicating directly from the client browser to the site that is hosting the web service (if you ask me, this is a lot better than calling the server side and then performing the remote method invocation).

How to install Sql Server Express with Advanced Services on Windows Vista
Wed, Sep 13 2006 4:57

I’ve just finished installing Sql Server Express With Advanced Services on Windows Vista. The hardest part was getting Reporting Services installed. The problem is that the default installation of IIS wasn’t enough. Fortunately, Microsoft has a kb with all the necessary IIS7 components that must be installed for the Reporting Services installation succeed:

http://support.microsoft.com/kb/920201

by luisabreu | with no comments
Filed under:
Another extender which make me believe harder…
Thu, Sep 7 2006 5:34

That ATLAS programming should be centered around the client, not the server side! Well, today I received a mail asking if I could take a look at a small sample which tried to use a regular AutoCompleteExtender (yack! Hey, look how AutoCompleteBehavior sounds much nicer than that previous name) which should invoke a remote web service. It’s true that I haven’t been playing much with ATLAS lately, but since I do like it, I’ve taken some time off to study some of its components (specially the client side). I knew that this should work because, internally, the AutoCompleteBehavior (which, as you might guess, is responsible for getting everything working on the client side) uses the Sys.Net.ServiceMethod class to invoke the web service. Due to that, we should be able to invoke local or remote web services. In fact, if you look at the AutoCompletebehavior class, you’ll note that the remote method is invoked through this line:

Sys.Net.ServiceMethod.invoke(_serviceURL, _serviceMethod, _appURL,
   { prefixText : _currentPrefix, count: _completionSetCount },
   _onMethodComplete, null, null, null,
   [ this, text ]);

As I said, I received a cool simple sample written by Rob Thijssen with two projects: a web service project and an ATLAS project with a simple page that tried to invoke the remote web service with this code:

<atlas:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server">
   <atlas:AutoCompleteProperties Enabled="true"
      MinimumPrefixLength="1" TargetControlID="TextBox1"
      ServicePath=http://localhost:3007/AutoCompleteService/Service.asmx
      ServiceMethod="GetNamesByPrefix" />
</atlas:AutoCompleteExtender>

According to Rob, it didn’t work. And yes, he was right…it didn’t work. Running the sample would return something like this:

The server method 'GetNamesByPrefix' failed with the following error:A web request made using the iframe executor failed. Make sure that the app's web.config registers iframecall.axd in its .

Wtf? It was then that I looked again at the AutoCompleteProperties and noticed that it’s missing a very important property…yes, it doesn’t have an appURL property!!! If you look at the AutoCompleteBehavior, you’ll find a property with that name which is passed to the ServiceMethod.invoke method. Well, you see, the team just decided that that property wasn’t important…in fact, it is important! You see, that property is used to define the app url that is hosting the web service and if you don’t set it, the server side iframe handler won’t be able to correctly process the remote web service call (and yes, it’s ok not to set it if the service is on the same app as the page that’s calling it). So, the 1st lesson is: always use the client side behaviors when possible.

Unfortunately, I’m not seeing most guys doing that (mostly due to the way ATLAS is being presented by MS). So, until the team fixes this, we’ll have to resort to a small workaround. Yes, you can extend the AutoCompleteProperties class, but it’s too hot to write server code (it really is – 33ºC at 23:15 is hot), so we’ll just have to resort to a client side approach to solve this.

What we need to do is inject client code that correctly sets up the AutoCompletebehavior used on the client side. Doing that is easily accomplished by this code:

<script type="text/javascript">
    Sys.Application.load.add( handle ); //handle the load event so that xml-script has been processed
     function handle( object, e )  {
          var ref = $object("<%= TextBox1.ClientID %>" );
          ref.get_behaviors()[0].set_appURL( "http://localhost:3007/AutoCompleteService/" );
     }
</script>

In the previous code, we just get a reference to the AutoCompleteBehavior and explicitly set its appURL property to the correct value (this works in this case because the textbox only has one behavior added to it). That’s all that needs to be done to use the current server side extenders (yack!) to call a remote web service from the AutoCompleteBehavior.

Btw: guys (ie, ATLAS team), the next time you decide to wrap a client behavior with a server extender, please do wrap all the properties…

[update: I've forgot to mention that you might need to enable ATLAS on the remote web site that is hosting the service since the client will call will the iframecall.axd handler of that site]

Portuguese videos about ATLAS
Tue, Sep 5 2006 17:34

As I’ve mentioned in the past, I’ve started producing some screencasts about ATLAS in Portuguese. I’ve built a simple site and feed that may be useful to those that speak Portuguese and want to learn about this new technology. Here’s the link:

http://curtas.pontonetpt.com/