Calling web services in web-enabled InfoPath forms

I'm pretty sure most of you are aware that you can build InfoPath forms to be hosted at MOSS as web-enabled forms. This is possible using the InfoPath Forms Services in MOSS.

If you ever tried using this type of forms you’ll realize that you will have some limitations compared to the forms that run inside the InfoPath client.

One technique to come over these limitations would be using Web services in your forms. For instance you can query a database if you have a web services layer encasulating the database server. Below are some hints to make your life easier.

  1. It is quite easy to setup a new data source that is accessing to a web service in InfoPath. You can develop and using your InfoPath client and click Preview to test it.
  2. You can use rules that are tied to buttons or form start & close rules (Tools – Form Options – Open and Save – Rules) to set Web service parameters, execute and assign the result to you fields.
  3. For your forms to be used they have to be either added as a content type or the connection definition in InfoPath has to be stored in a connection library
  4. To add your form as a content type navigate to manage forms in Central Administration. Here you can add your form and enable it for your site. To use a connection library click the convert button on InfoPath while you have the data connections dialog box open. Don't forget that you have to do either of these to have a web enabled InfoPath form to call web services.
  5. Now you can create a forms library where the default form is your form which is calling web services.
  6. In one customer we had some errors executing the web service and figured out that the reason was anonymous access being enabled using Central Administration and disabling it solved our problem.