How to: Verify a Form Template Before Deployment

SharePoint 2010

Last modified: July 06, 2010

Applies to: SharePoint Server 2010

Browser-compatible InfoPath form templates can be verified before they are deployed to a server that is running InfoPath Forms Services. Verifying a form template ensures that problems with deployment can be addressed before they are deployed. Much like using the Verify on server option on the Design Checker task pane in the InfoPath design UI, verification can be done through the SharePoint 2010 Central Administration Web site or with code by using the VerifyFormTemplate method of the FormTemplateCollection() class.

To verify a form template using the SharePoint Central Administration web site

  1. Prepare a form template requiring administrator approval for publication using the Publishing Wizard. For steps to do this, follow the first procedure in How to: Deploy Form Templates That Contain Form Code That Requires Full Trust.

  2. Open the SharePoint 2010 Central Administration site.

    Note Note

    You must be a member of the Farm Administrators group in order to complete this and the remaining steps.

  3. Under General Application Settings, click the Manage form templates link.

  4. Click the Upload form template link near the top of the page.

  5. Click the Browse button to open a dialog box, and type the path of the published form template.

  6. Click the Verify button to verify that the form template is ready for uploading to the server.

To verify a form template using the VerifyFormTemplate method of the FormCollection class

  1. Prepare a form template that requires administrator approval for publication by using the Publishing Wizard. For steps on how to do this, follow the first procedure in How to: Deploy Form Templates That Contain Form Code That Requires Full Trust.

  2. Open Visual Studio.

    Note Note

    These steps require that Visual Studio is installed on a computer that is running InfoPath Forms Services.

  3. Create a new Console Application in either Visual Basic or C#.

  4. Right-click the project in the Solution Explorer, and then click Add Reference.

  5. On the .NET tab of the Add Reference dialog box, select Microsoft SharePoint Foundation, and then click OK. (If Microsoft SharePoint Foundation is not available on the .NET tab, on the Browse tab, browse to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\, select the Microsoft.SharePoint.dll assembly, and then click OK.

  6. Repeat step 3 and in the Add Reference dialog box, click the Browse tab.

  7. On the Browse tab of the Add Reference dialog box, browse to C:\Program Files\Microsoft Office Servers\14.0\Bin\, select the Microsoft.Office.InfoPath.Server.dll assembly, and then click OK.

  8. Copy the following code example, depending on the language that you chose in step 2, and paste it into the code window.

  9. Change the SolutionPath variable to a location where you have published a form template for administrator approval.

  10. Save the project and press F5 to debug and run the code.

The count of converter messages and any additional messages will be displayed in a console window.

The following code examples use the VerifyFormTemplate method to show converter messages, if any, in a console window. The location of the form template is stored in the SolutionPath variable and should be changed to match the path of the form template that you want to verify.

Imports Microsoft.SharePoint.Administration
Imports Microsoft.Office.InfoPath.Server.Administration

Module Module1

    Sub Main()
        Dim LocalFormsService As FormsService
        Dim LocalFarm As SPFarm
        Dim SolutionPath As String = "C:\FormTemplates\FormTemplate.xsn"
        Dim VerifyMessages As New ConverterMessageCollection
        Dim ConverterMsg As ConverterMessage
        Try
            LocalFarm = SPFarm.Local
            LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
            VerifyMessages = FormTemplateCollection.VerifyFormTemplate(SolutionPath)
            Console.WriteLine("# of messages: " + VerifyMessages.Count.ToString())
            For Each ConverterMsg In VerifyMessages
                Console.WriteLine(ConverterMsg.ShortMessage.ToString() & ": " & ConverterMsg.DetailedMessage.ToString())
            Next
            Console.Write("Press Enter to Continue")
            Console.ReadLine()
        Catch ex As Exception
            Console.WriteLine("Error: " + ex.Message)
            Console.Write("Press Enter to Continue")
            Console.ReadLine()
        End Try

    End Sub

End Module
Show: