Wednesday 25 June 2008

Browser compatible InfoPath form linked to a web service

I had to create an InfoPath form to submit data to a SQL 2005 database and was surprised you can't submit to SQL directly if you run the form from the web browser. Instead you need to write a web service which will link InfoPath form and SQL database.

So I write a simple webservice and create the InfoPath form which I link to this service. Run the form from InfoPath to test it; submit data successfully and checked on the database that the web service done its bit. Published the form to MOSS 2007 so everything done... Not!

I had to:
  • In the form options
    - under Compatibility tick "design a form template that can be opened in a browser or InfoPath and enter URL of the MOSS with InfoPath Form Services;
    - under Browser Choose to show toolbars and Submit command;
  • In Tools / Data Connection convert the data connection and store it on the same MOSS (link type Relative to site collection);
  • In Tools / Submit Options tick "Allow users to submit this form" and set it to send form data to a web service;
  • Publish form to the SharePoint server.
  • In the SharePoint library on the lib settings go to Advanced Settings and make sure that under Browser-enabled Documents that browser-enabled docs are displayed as a web page.
Now it's done. I think... It works anyway...

5 comments:

Vekondja K. said...

Hi Dreri,

I am trying to do something similar but am struggling with the web service bit. Would you mind elaborating on how you did it?

Thanks

Unknown said...

Hi Mbara,

can you please tell me how far did you get, or I struggling to start it off?

Might be easier to just help you out with few points you stuck with rather than write the whole thing. Wish I had time to do it not just for you but for me as well but I'm a bit stretched for time lately.

Cheers,
Dreri

Anonymous said...

Hi again Dreri,

Hate to put you in this position but I pretty much dont know where to start. Infopath is okay, Sql is okay and its just that middle web service bit thats the pain.

Coding isnt my strength but I'm no knob either.Need to know what I should put where in my web service to take data submitted in Infopath and save it to a database. A general idea of what my .asmx file should look like and the commands to perform the submitting to an Sql database would be a great help. Even a one record example would be perfect, just to get the gist of it.

Thanks in advance, Mbara Kuzee

Anonymous said...

Hi Dreri,

Mbara here, just letting you know that I came right. A lot of trial and error has paid dividends.

Thanks for a cool blog,

Unknown said...

I created an InfoPath form that submits an SQL Server database through a web service. It works well until you try it with Sharepoint, then it does not submit.
I created the data connection library connections, and I have connected the InfoPath file udcx. I have also gone to the central administrator, and I have enabled "Allow Users to enable form templates for your browser" and "Require SSL for HTTP authentication to data sources", but it still does not submit. Any ideas?

Thank you very much