How to: Verify a Form Template Before Deployment
Browser-compatible InfoPath form templates can be verified before they are deployed to a server 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 3.0 Central Administration Web site or with code using the VerifyFormTemplate method of the FormTemplateCollection class.
Verify a Form Template using the SharePoint Central Administration Web site
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.
Open the SharePoint 3.0 Central Administration site.
Note
You must be a member of the Farm Administrators group in order to complete this and the remaining steps.
Click the Application Management link.
Under InfoPath Forms Services, click the Manage form templates link.
Click the Upload form template link near the top of the page.
Click the Browse button to open a dialog box, and type the path to the published form template.
Click the Verify button to verify that the form template is ready for uploading to the server.
Verify a Form Template Using the VerifyFormTemplate Method of the FormCollection class
Prepare a form template requiring administrator approval for publication 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.
Open Microsoft Visual Studio 2005.
Note
These steps require that Microsoft Visual Studio 2005 is installed on a computer running InfoPath Forms Services.
Create a new Console Application in either Visual Basic or C#.
Right-click the project in the Solution Explorer, and click Add Reference.
On the .NET tab, select Windows SharePoint Services and click OK.
Repeat step 3 and in the Add Reference dialog box, click the Browse tab.
In the Look in box, navigate to the location where Microsoft Office SharePoint Server 2007 or Microsoft Office Forms Server 2007 is installed, typically
C:\Program Files\Microsoft Office Servers\12.0\
, double-click theBin
folder, then inside this folder, select Microsoft.Office.InfoPath.Server.dll and click OK.Copy the code example below, depending on the language you chose in step 2, and paste it into the code window.
Change the SolutionPath variable to a location where you have published a form template for administrator approval.
Save the project and press F5 to debug and run the code.
The count of converter messages as well as the messages, if any, will be displayed in a console window.
Example
The 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
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.InfoPath.Server.Administration;
namespace VerifyFormTemplate
{
class Program
{
static void Main(string[] args)
{
FormsService localFormsService;
SPFarm localFarm = SPFarm.Local;
string solutionPath = "C:\\FormTemplates\\FormTemplate.xsn";
ConverterMessageCollection verifyMessages;
try
{
localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
verifyMessages = FormTemplateCollection.VerifyFormTemplate(solutionPath);
Console.WriteLine("# of messages: " + verifyMessages.Count.ToString());
foreach (ConverterMessage convMessage in verifyMessages)
{
Console.WriteLine(convMessage.ShortMessage.ToString() + ": " + convMessage.DetailedMessage.ToString());
}
Console.Write("Press Enter to Continue");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.Write("Press Enter to Continue");
Console.ReadLine();
}
}
}
}