Wednesday, August 30, 2006

Using webservices in browser-enabled forms with InfoPath 2007 Forms Services

InfoPath 2007 in combination with either Microsoft Office SharePoint Server 2007 or Windows SharePoint Services allows you to create web-enabled InfoPath forms - this means that you don't need a full InfoPath client installation to let your users fill in a form.(For more info see InfoPath Forms in Office SharePoint Server 2007). To make a InfoPath 2007 form web-enabled - you simply publish it to a SharePoint forms library. Next you go to the Forms library Settings > Advanced Settings. Change Opening Browser-enabled documents to Display as a web page.

 






These web-enabled forms do have some limitations however as outlined in this post - Functionality lost in InfoPath 2007 "Web-Enabled" Forms. InfoPath has always been very strong at consuming web services and using data returned from these web services in the forms. If you want to use a web service as a datasource within an web-enabled InfoPath form there are some things you need to do to accomplish this - especially when you use a webservice which does not run within the context of SharePoint. When you access a webservice from an web-enabled InfoPath form, Internet Explorer will consider this as a cross-domain setup. So your InfoPath form may work correctly when opening it from your SharePoint with the full client but will give an error when opening in the web browser - "An error occurred accessing the data source in the browser" when not configured correctly.

So here are the steps that you need to complete to get it to work:

  • First make sure that cross domain access is enabled for InfoPath Forms Services - Go to SharePoint Central Admin > Switch to the Application Management tab. Underneath InfoPath Forms Services - Choose Configure InfoPath Forms Services. Check "Allow cross domain access for user templates"
  • Use the Data Connection Library to store the connection setttings to the web service. A Data Connection Library (DCL) is a new type of SharePoint document library which provides a place to store, manage and share connection files. For more info about DCLs - check out Excel Services part 10: Data Connection Libraries, or connecting to databases made easy, manageable, and secure .  Open your your locally saved InfoPath 2007 form in Design View. Select Tools - Data Connections. Select your web service connection and click the Convert button. For the name enter something like http://servername/DataConnectionLibName/WebService.udcx (Ignore the warning that you get ... this will be fixed in post beta2 builds) Once the connection has been converted to a data connection file, save the form locally again and  publish it to the SharePoint forms library.

Voila, and now you can use your webservice as well from an InfoPath form within the browser ... if you have questions, do no hesitate to add it to the comments ...

tags: , , , , , ,,

16 comments:

Anonymous said...

Hi,

i have a web-enabled infopath form with c# code behind. i can publish the form into sps and work with this form.

i would like to access a webservice from c# code to submit data and retrieve an id back.

i created an webreference in my vsta project.

i get an security exception when i try to connect to the webservice.

how can i access a webservice from c# code?

thanks

Anonymous said...

Hi,
I can not find the data connection library in WSS-v3.0. And I can not setup the MOSS 2007.
So I can not convert the data connection.
Why? Hoe can I do?

Thanks

ken

Anonymous said...

Hi,
I can not find the data connection library in WSS-v3.0. And I can not setup the MOSS 2007.
So I can not convert the data connection.
Why? Hoe can I do?

Thanks

ken

Anonymous said...

Hi,
I can not find the data connection library in WSS-v3.0. And I can not setup the MOSS 2007.
So I can not convert the data connection.
Why? Hoe can I do?

Thanks

ken

Anonymous said...

Hi,
I can not find the data connection library in WSS-v3.0. And I can not setup the MOSS 2007.
So I can not convert the data connection.
Why? Hoe can I do?

Thanks

ken

ken said...

Hi

I must setup MOSS 2007 if I want use Data Connection Library ?

I just setup the WSS V3.0 + Forms Server. How can I design form base on the web service and can open with the browse.

thanks
ken

jopx said...

Data connection libraries are indeed a MOSS only feature...

Simran said...

excellent post!

Anonymous said...

Yeah. This fixed my issue too. Thanks for posting.

Anonymous said...

Hi,

My problem is pretty different. I have a browser enabled infopath form which has managed code. On running the form, on any button click the control doesn't go to the corresponding method but pops up an error "Unexpected end of file has occurred. The following elements are not closed: dfs:dataFields, dfs:myFields.". How can I debug this error?

Thanks

Anonymous said...

InfoJet Service, a product likes InfoPath Forms Services.
http://www.infojetsoft.com

Sabrish said...

Even after following all the above steps, I still get an error.

Smac's SharePoint said...

spent ages on this, it was wrecking my head. Had deployed the form but was getting the error you listed. Thanks a mill for taking the time to post the info and screenshots. Works a treat now.
Eoin.

Anonymous said...

Hi.

I find this Article really usefull, but i have found a problem very frustrating:

When i publish it into MOSS 2007 i have no problem to publish it, but when i open the form the error 5566 appears..

To solve this, i have tried to publish it from MOSS.

But when i go to load the form manually, it says that the template is not enabled for the explorer, but i have checked it and i have saved the template to be used with explorer....

any idea of why is this wrong??

thx

jopx said...

Veelicus - could you provide the exact error details?

Jeremy Thake said...

I still get Error ID 5566 even when using Data Connection Library and then even moving up to the Central Administration Managed Data Connection Files.
The form works fine when forcing it to open in the InfoPath client.

I found this article relating the error to Proxy, but we're not using a proxy.

Any help would be greatly appreciated! Removing the Data Connections makes the form work without any errors.