Monday, 11 July 2011

Building a WCF Web Service for InfoPath data

Problem: Create a WFC web Service to store an InfoPathForm

Initial Hypothesis:  Project consists of 3 parts: 1)SQL Server table for storing form data, 2)WCF web service for exposting the storage web service method and 3) consuming the Web Service using infoPath.

1) SQL Script to create the datbase table.  Once the table is available for storage we need to build the WCF web Service.
2) WCF web service:
2.1) Add the LINQ to SQL proxy (dbml file) to persist the data
2.2) Assign
2.3) Wire up the WCF WS
Edit as needed (apply business logic)
2.4) Expose the WCF thru an IIS website on your Dev machine (Create an IIS web site to host the WCF):
2.5) Publish the WCF using VS2010 as shown below to the local machine
Ensure the WCF service is available using the browser.

3) Consuming the WCF WS in InfoPath forms

How to Add a Service Reference?

1.> Ensure the WCF exists i.e. http://wcf-service/FormService.svc

2.> Generate the WCF proxy (VS > Right click the WFE project > Add Service Reference > Insert the url and save the WS reference)

3.> Copy the contents of the app.config bindings & endpoints elements into the web.config (this needs to be automated in the deployment script thru a configurable feature) Web.config is shown below:

4.> Call the WCF web Service (consumer)
WCFBanner.BannerClient ws = new WCFBanner.BannerClient();
WCFBanner.PatientBanner pb = ws.GetPatientBannerByPatientId("G3");
lit1.Text = "PatientId: " + pb.PatientId;

Additional Info:
Comparing SharePoint InfoPath lists vs forms


Ali said...

I am doing exactly the same thing..Do you have part 2 of the post where you show how the WCF is consumed in a form?

Murugesa Pandian said...

yes ! curious to see how you consumed the WCF data in InfoPath form

Nate said...

Murugesa and Ali,
In the Infopath data connections, you select the "Submit data " through WCF service .
Here is a usefull link


Post a Comment