Search code examples
asp.net-mvc-3orbeon

How to get Orbeon Forms embedded into an ASP.Net MVC3 app?


Background

I'm investigating the use of Orbeon Forms to integrate into our ASP.NET MVC3 web app by building a simple MVC3 app to figure stuff out.

I have a Win2008 R2 std server running Tomcat 7 and Orbeon 3.9.1 PE trial on our HyperV server. This is working and I can create forms and then use the forms to submit data.

I've created an empty MVC3 app on my local dev machine. It has an Index action on the Home controller that returns a page that has a bunch of links to the add new URLs of some of my forms on the Orbeon installation. The links access an Add action on the Home controller which uses a WebRequest object with the ?orebeon-embeddable=true querystring parameter tagged on the end to get the definition of the Orbeon submit form page. I replace the relative URLs in what I get back to make them absolute. I then insert that into a basic view and display it.

Problems

HOWEVER! As soon as I do interact with the Orbeon form in anyway, e.g. click inside a single line textbox field (IE9) I get a JS error in the script file "orbeon-[random guid style value].js" line 121 with the line "AjaxServer.exceptionWhenTalkingToServer(e,formID)" highlighted with the error being "formID is undefined".

I'm not sure where to start looking here as I am unfamiliar with Tomcat and only know what I can decipher from the Orbeon docs.

Anybody tried to embed the form runner like this and experience this error?

What I tried next

[Update]: The MVC Json() method got me thinking that perhaps the Orbeon test site I set up on the VM did not like the fact it was getting AJAX requests from the MVC app on my dev machine. With this in mind I tried installing the CORS filter into the Orbeon app from dzhuvinov.com. According to the docs after adding the relevant config to the web.xml file the default behaviour is to pretty unrestrictive, i.e. it should let everything through. Unfortunately after restrating Tomcat this didn't help.

[Update 2]: Okay seems like the CORS docs are a bit out of date and the defaults are seemingly the opposite so setting the initial values for that seems to sort that out somewhat - although IE9 still gets the JS error message. Meanwhile in FireFox 12 things are going better but now the issue is how to pass the JSESSIONID cookie Orbeon sends me back when I embed the runner in the MVC view such that when you trigger any of the AJAX on the Orbeon form it sends the JSESSIONID cookie as well.


Solution

  • Well I guess my title and info were slightly misleading so I may as well close my own question with the follow "answer".

    In order to embed in an MVC3 app (read as any non-Java backend I would imagine) Orbeon Forms Runner and have it work I had to do the following:

    1. Configure the CORS filter for my install of Orbeon Forms on Tomcat 7 (Dzhuvinov.com) to allow cross-domain AJAX.
    2. In HTML partial's returned from Orbeon make relative URLs beginning /orbeon/xforms-server/ absolute calls to a custom proxy. Store the JSESSIONID in the ASP.NET MVC Session object.
    3. Write controller actions for the proxy to handle requests. This simple proxy forward requests on to the Orbeon Forms install after setting the JSESSIONID cookie with the value stored in (2).