In this blog posting, I will take you step by step on creating an InfoPath Form that connects to a web service stored on another server (normally causing cross-domain issues).
The business need:
- SharePoint List – A SharePoint List to hold SoE documents (Separation of Employment)
- Employee’s Location Drop Down Box – The employees have different locations, but there are many locations they work at. So we need a drop down box for the Employee’s Location, but this has to come from a database, I chose to create a web service as a proxy.
- Employee’s List Populated – Based on the employee’s location, the list of employees should populate.
- Auto Staff ID filled Out – When the employee is selected, the Staff ID should be filled out.
Here is the final result.
Web Service Methods:
I created an ASMX service because I knew for sure that it would be compatible with Microsoft InfoPath for sure. I didn’t want to create a WCF service that did this just to find out it didn’t work with InfoPath.
- When the form loads, the employee’s locations are populated using GetLocations in the web service
- When the user selects the employee’s Location, the list of employee’s drop down box populates.
- when the employee is selected, then the employee ID is filled out.
- First, you must select your web service after it has been deployed.
Next, convert all of your web service to a SharePoint connections library. This will deploy all of your connections and allow your InfoPath to use it directly.
Now, you must ensure that cross domain settings are turned to allow in InfoPath Form Services. In Central Admin, go to General Application Settings, then Configure InfoPath Form Services…
Next, turn on Allow for Cross-Domain Access for the User Form Templates, this enables you to use a separate server for the web service.
To enable rules, you will need to right click on one of your controls, then select Rules and Manage Rules…
For the first field, Employee’s Location, you will have to set up rules so once it is selected your InfoPath form performs an action, and that is to:
- Set the GetEmployeesNameByLocation location field to the selected Employees Location field
- Perform the query on GetEmployeesNameByLocation
- Now, your rules should look like this:
And by this time your Employee’s drop down should be populated.
I will not take you through the rest of the examples to get to this point, but please let me know if you have questions, I can fill out more to my blog if questions arise.