Sign in
Philo's WebLog
Musings of a former Office Developer Evangelist
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
About
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Tags
Book Review
Business Intelligence
Developer
InfoPath
Non-Tech
SharePoint
Smart Documents
SQL Server
SSIS
Archive
Archives
February 2009
(1)
August 2008
(1)
April 2008
(1)
November 2007
(1)
October 2007
(4)
September 2007
(4)
February 2007
(3)
January 2006
(1)
November 2005
(1)
October 2005
(1)
April 2005
(2)
June 2004
(2)
April 2004
(6)
March 2004
(2)
Creating a web service for an InfoPath form in 25 easy steps
MSDN Blogs
>
Philo's WebLog
>
Creating a web service for an InfoPath form in 25 easy steps
Creating a web service for an InfoPath form in 25 easy steps
Rate This
MSDNArchive
8 Nov 2005 12:07 AM
Comments
9
It took me a while to figure out how to do the InfoPath/webservice thing starting with an InfoPath form. Maybe this is blindingly obvious to everyone but me, but here it is anyway:
1) Create an InfoPath form from a new, blank form:
2) Lay out your form, using sections, grouping, and naming controls as appropriate:
3) Extract the form files (File | Extract Form Files) to a location you can find later.
4) Open Visual Studio .Net (I'm using 2003 in this example; this will work with 2005 as well. Remember - we're only building the web service in VS.Net; not InfoPath code)
5) Create a new ASP.Net web service project.
6) Switch to the code view of Service1.asmx and note the namespace. (Rename Service1 or add a new Web Service if you choose to)
7) Open the Visual Studio command prompt:
Start | All Programs | Microsoft Visual Studio .Net 2003 | Visual Studio .Net Tools | Visual Studio .Net 2003 Command Prompt
8) You'll have to either close InfoPath or copy the myschema.xsd to another location (the file will be locked by InfoPath in design mode)
9) Go to the location you specified in step 8. Run xsd against the myschema.xsd in that directory; specify the namespace to the namespace from step 6:
xsd.exe myschema.xsd /classes /l:cs /n:InfoPathFormService
10) You'll now have a myschema.cs file. Add that to the web service project (right-click on the project, Add -> Existing item)
11) Define a new webservice method:
[WebMethod]
public
void SubmitForm(myFields newForm)
12) myFields is the root of the object model for your form:
13) Put any logic in the WebMethod you need to parse the values out of the form, perform business logic, update databases, etc.
14) Finally, let's hook the InfoPath form to the submit webservice. Publish the web service to a web server:
15) Copy the URL of the web service.
16) In the design mode of our InfoPath form, open Tools | Submitting forms:
17) Enable submit commands and buttons, select "Web Service" for "Submit to"
18) Add a data connection, paste the URL of your web service in the location box:
19) Next, then select the operation for your submit form action, then Next > again:
20) The next dialog will prompt to match the form's submission to the web method's parameter. Select "Field or group" then click the node button to the right of the text box:
21) Select the myFields node, then click "OK"
22) Select to Include the XML Subtree, including selected element
23) Next, Finish, then OK
24) Publish your form
25) Now, when users fill out the form, they can save it to their local drive as an XML file, or submit it to your web service.
9 Comments
InfoPath
Blog - Comment List MSDN TechNet
Comments
Loading...