Project Overview
We will develop a solution that will enable MCMS Authors to
maintain content stored in the MCMS repository using InfoPath 2003 via
ASP.NET Web services.
The
user will be able to launch a single InfoPath form and select the
posting they wish to modify, which can be based on any MCMS template. A
Web service call will then be made that loads the posting, placeholders,
and custom properties from the MCMS repository, using the MCMS
Publishing API (PAPI). The InfoPath form will then be populated with
this data so the user can make their modifications to the content. Once
the changes are complete they can then be sent back to the ASP.NET Web
service and saved to MCMS.
For simplicity the solution outlined in this chapter will only permit editing of HtmlPlaceholders and Text
custom properties of existing postings, but it could be extended to
create new postings, use different types of placeholders, and to set
selection custom properties. For further enhancement ideas, see the Possible Enhancements to this Solution section at the end of the chapter.
The form we will create
retrieves and displays the posting and template details, and allows
modifications to the custom properties and placeholders. The
placeholders will use InfoPath’s rich text control that allows
formatting of the content. A bonus of this solution is that all
placeholder content will be transformed into XHTML (Extensible HyperText
Markup Language, which at its most basic level is HTML that conforms to
XML standards) as InfoPath’s data is stored in XML.
What are ASP.NET Web Services?
ASP.NET
Web services allow software developers to create an interface for their
application that supports integration across application domains.
ASP.NET Web services consist of one or more Web methods. Web methods are
like methods of regular .NET objects, but are invoked over a network
and executed on the server that hosts the Web service. This is similar
to Remote Procedure Calls (RPC) and DCOM object invocation.
When calling a Web
method, parameters may be passed and any return value can be retrieved.
As the method call is sent to the machine hosting the Web service using
HTTP, the objects being passed as parameters are transformed into a
format suitable for transmission. In this case, XML serialization is
employed, which is the process of converting an object from its binary
form in memory to HTTP-safe XML format.
We have chosen to use ASP.NET
Web services to integrate InfoPath with MCMS as it allows us to use the
robustness of .NET while maintaining a flexible GUI built in InfoPath.
Web services are platform independent and are also the preferred
integration method for InfoPath. Another possible solution would be to
develop the code within InfoPath by scripting the queries to MCMS and
handcrafting the InfoPath form, but we would then lose the benefits of
having one centralized store for business logic and processing thus
reducing our ability to scale and support the solution.
Creating the MCMS Web Service Project
The MCMS Authoring Web
service will access MCMS via the Publishing API. A series of Web methods
will allow developers to retrieve template details, and update
postings. The MCMS Authoring Web service project will be created from
the MCMS Web Service project template in Visual Studio .NET 2003. The
MCMS Web Service project template automatically includes the correct
references and web.config entries to talk to MCMS.
Let’s go ahead and create this ASP.NET Web service application:
1. | Launch Visual Studio .NET and from the File menu, select New | Project.
|
2. | From the Project Types panel, select Visual C# Projects under Content Management Server Projects.
|
3. | From the Templates panel, select MCMS Web Service.
|
4. | Enter the location as http://localhost/McmsAuthoringWebService and click OK.
|
A project should now be created and you will notice all the required MCMS references are already created. You can delete the Console folder from the project as we do not need it.