Thursday, April 23, 2009

Submitting data from Infopath form to SQL Server database using WebService

Step 1. Create a Form with some fields.

Step 2. Make that form Full trust using following steps
1. Select Tools --> Form options
2. Select "Security and Trust" menu item from left.
3. Enable Full trust option "Full Trust (The form has access to files and settings on the computer)"

Step 3. Create a webservice that can read this form XML and insert data into SQL Server

Step 4. Add a Submit button on form to submit its data to SQL Server,follow below steps for this
1. Add a button on form from controls box.
2. Right click on that bottom and click on "Button Properties".
3. Now from the "Action" dropdown select "Submit" option.
4. There'll be a button below it "Submit Options",click on it.
5. Enable "Allow user to submit this form" option.
6. Select "Web-Service" option from the dropdown.
7. There'll be a button "Add" under heading "Choose a data connection for submit" , click on it.
8. Enter location of the web-service you want users to submit their form to(Virtual path of web-service like http:\\ws.abc.com\\MyService.asmx).
9. Click on next.
10. Now Select method (from left side menu) in which you want to submit this form.
11. Click on next.
12. Enable "Entire form (XML document, including processing instructions)" option.
13. Click on next.
14. Now Enter a name for this data connection.
15. Click on Finish.
16. Now click on OK on other window.
17. Now click Apply and and then OK.


So now the button on form is ready to submit this form to a web service. you can now submit this form data to Web Service.

But ! , without publishing this form to share-point site you cannot submit this form.Please read other post "Publishing a full trust form on share-point site" to publish this form on sharepoint site.


Thanks,
Vikas Sharma

No comments:

Post a Comment