Upload
barrie-flynn
View
214
Download
0
Embed Size (px)
Citation preview
INFOPATH 2010
Tom Castiglia
Hershey Technologies
Twitter: @tomcastiglia
www.sanspug.org
Agenda Building “web applications” with InfoPath
and WCF ServicesNot just traditional “forms”
Using Data Connections and Rules to connect InfoPath forms to custom services or existing servicesShort Slide deck
Live InfoPath/SharePoint Demo
Target Audience Middle Tier Developers
Expose your middle tier business logic as a service (cloud or on-premise)
Use InfoPath as a RAD tool to easily build web UIs that can easily consume your custom services
End-Users, Business Analysts & IT staffUse InfoPath as a RAD tool to easily build web
apps and forms that can easily consume existing services
InfoPath Data Connections
The “plumbing” in your InfoPath form
Allows you to configure the
connections between back-end systems and your form’s UI.
Types of Data Connections
• SOAP• REST• WCF• Azure
Web Services
• SQL Server• ODBC• OLE-DB• Oracle
Databases
• SharePoint• File serverXML files
• Convenient alternative to using a database table
SharePoint lists / libraries
InfoPath Rules Rules are like the application programming logic for
your form Rules can be used to…
Pass form data as an input parameter to a data connection Bind the data connection’s return values to other form fields
Types of Rules
• Specify an error message that will be displayed condition is falseValidation
• Changes “look and feel” of the UI elements (show/hide, color, fonts, etc.)Formatting
• Connect data connections to your form fields• Set input param values from form fields• Assign results from back to the fields
Action
Why use Data Connections & Rules? Build rich, functional applications without code Common examples:
Populate a drop-down field
with values.
Generate unique,
incrementing ID values
Pre-fill portions of the form with
existing data
Send data to back-end
databases and applications
Perform real-time validations
of user input
Incorporate forms into workflow
processes
Data Connection Tip #1
• Limited to tables and views• Cannot call a stored
procedure directly
Database connections
• Requires a developer to implement services
• WCF is “best-practice”
Web Service
connections
Data Connection Tip #2
When connecting to WCF services, typically use the “Receive data” option. (Even if your service is used to save, update or delete
data.)
Use “Submit data” only when you want to submit (and close) the entire form.
Data Connection Tip #3 When connecting to a WCF service, select the
option called “SOAP Web service”.
This applies to any type of service that has a WSDL file (SOAP, WCF, Azure, Java)
You must know the URL for your WSDL if you select this option.
Data Connection Tip #4 You can specify default values for the input
parameters of your data connections, if user input is not required.
Data Connection Tip #5 Uncheck the option to “Automatically
retrieve data…”
This option is checked by default. Leave enabled if the data connection does
not require user input.
Data Connection Tip #6
This allows connections to be re-used on multiple forms
Prevents security warnings from being displayed when form is used
Start by setting up data
connections
Save connections to a Data Connection
Library
Approve the Data
Connections in the library
Demo - Universal auto-incrementing Id
Implement new service using SQL Server WCF (VS2010 & C#)
Easily reusable for all InfoPath forms This technique is a “best practice”,
compared to using SP list ID values or DocumentId
FormCounters (table) Simple table, with two columns:
FormName (VARCHAR (50), PK) FormCounter (INT)
Used to track the counters for any number of different forms
GetIncrementedCounter procedure
• Validate that the specified FormName is valid and raise an exception if a bogus value is provided
• This will save much troubleshooting time down the road when someone accidentally tries to use an incorrect value for the FormName
GetIncrementedCounter procedure
• To ensure concurrency in a multi-user environment, two things are important:
• Using a Transaction• Proper row level locking
• UPDLOCK• XLOCK
Configuring IIS 7 for a .NET 4.0 based WCF Service• If you plan to deploy your service on the SharePoint WFE, then be sure to run
that web site on a port other than the port(s) used by SharePoint• Make sure the web application is in an application pool configured with
• .NET 4.0 framework• Identity set to the built-in “ApplicationPoolIdentity”
• Create a new application under your web site to host the service
Configuring SQL Server security• Add new windows login to SQL Server: “IIS APPPOOL\DefaultAppPool”• Give this account access to the database hosting the FormCounters table• Grant Execute Permissions to the GetIncrementedCounter procedure