Rafal Ziolkowski, Software Development

Lotus Notes, Microsoft .NET, ASP.NET, Sharepoint, SQL Server

Problem
How to get list of unique text values from XML document, for example to build a kind of dictionary from these node values.

Solutionnodename is name of node to select from. preceding axis get everything what is before start tag of selected node.
It is also possible to use following axis to get everything what follows current node, with this axis, XPath will return results in reversed order

It is easy to obtain data from view as XML string, but to get this data as JSON it seems to be hard work.... not exactly :) I have just found really usefull parameter called Outputformat where we can set value JSON.

Here is how does it look:http://<your server here>/<your data base here>.nsf/<your view here>?ReadViewEntries&Outputformat=JSON

In last article I showed how easy is access to .NET WebService from ExtJS JavaScript Library. This solution has one big disadvantage. Due to security reasons HTTPRequest method used for performing AJAX calls is restricted to in-domain calls only. What in the case if our WebService is located on different machine and different domain? You will find answer for this question in this article.

Solution

As I mentioned before it impossible to access data located in different domain using HTTPRequest method, but we can use some trick. It is possible, using JavaScript to add any html tag to current document - even SCRIPT tag. As all we know SCRIPT tag allows to include JavaScript code into document and also SCRIPT tag can have URL where JavaScript code is located. This is not limited to the same domain, like in HTTPRequest case. Let's imagine that our source code in this case is remotelly and dynamically produced data returned as valid JavaScript code. When document is ready, we can acces this data and that's all. There 2 drawbacks of this solution. Performace is slightly worse (we need to call some remote domain, etc) and we have to prepare server side to handle script-tag requests. On ExtJS side we can just use ScriptTagProxy object class instead of regular HttpProxy.

Hey, does it look like JavaScript function call with our data provided as parameter? Yes exactly! Name for callback function is provided by ScriptTagProxy class as parameter added to URL. Default name for this callback is... callback. URL to acces remote data source will look like this:

Now we need figure out how can we make our web service work with ScriptTagProxy. It could be easilly achieved with solution called PageProxy. What is PageProxy? In simple words: this is an aspx web page wich will receive all requests, and using reflection forward them to web service, then it will get back the response, enclousure with javascript callback function and forward it to request's sender.

ExtJS is very powerful JavaScript library, perfect for creating rich graphical user interface in web browser. You can make applications of many purposes and integrate data from many sources and technologies using XML, JSON or own interchange format. On the other hand .NET provides great server side features like entity framework, Linq and many more powerful classes. In this article I would like to show You how to integrate both technologies in the most convenient way and use strengths from both of them.

Solution

When You are trying to access different data sources on different servers, the best way in today's world is to use web services. In this way You can build SOA solution, accessible by many suppliers using different technologies. When we have decided to use ExtJS as GUI part and ASP.NET as server part, it would be ideally to use ASP.NET web services directly. Natively ExtJS does not support SOAP XML data source. You can write own data proxy if You like, but I will show You that it is not necessary. ASP.NET webservices, starting from version 2.0 allows You to talk in JSON format instead of SOAP XML.

Like in most cases, when You want to configure behavior of .NET classes You can use attributes. In this we need to decorate web service class with ScriptService attribute (form System.Web.Script.Services namespace), and then decorate methods with ScriptMethod attribute. Class attribute does not need any configuration, but we have to add some to method decorator also. All we need to specify is method response format, in this case ResponseFormat=ResponseFormat.Json and allow to talk to web service method using GET HTTP method. That is all we need on server side, let's go then to GUI part.

In this scenario we have obtained data from ASP.NET WebService and show it in ExtJS data grid. This approach has one big disadvantage: WebService have to be located within the same domain. In the next article I will show You how to perform Cross domain call from ExtJS to ASP.NET web service in simple steps.

ProblemWhile using Ext.ux.Chart.OFC.Panel I have encountered problems with statically delivered data (from js). I made panel embedding ofc panel, and I have created ofc panel in the simplest way (in my opinion):

When You will try to perform remote call to WebService made in Lotus Domino with access allowed only for authenticated users You will get login screen as an response. It is possible to disable this feature by setting "allow public access" true on WebService design element, but for security reasons it is not recommended. It is possible to send authentication information using two scenarios: Basic Authentication and Cookie Based Authentication.

Basic AuthenticationThis scenario is quite easy. It requires Internet access in Domino set to Basic Authentication.

Cookie Based AuthenticationSecond scenario is more complicated, but thanks to .NET power it is possible to do. It requires Internet access in Domino set to Session-based authentication or Single sign-on.

Normally if You declare store in ExtJS the default HTTP method is POST. Sometimes You need send data using GET method, so ExtJS is fortunatelly flexible enough to make it possible. You'll just need to create You own HttpProxy and change this proxy method to GET.