Overview

These services are designed to be used by an application and not a user. The goal is offer 2 different services that provide capabilities to embed XML data into a Word document and retrieve it from Word document. It’s the way for an application to change content of Word document based on metadata values or external data. Office doesn’t necessary be installed on the machine, services don’t use it. The Word document can be used off line. Data are embedded into Word using custom XML part feature of Word. To use Embedded XML data into your document, you must have an Add-In in Word. You can use simply “XmlMapping” Add-In that you can download at http://xmlmapping.codeplex.com. Note you can add more than one xml data file into one Word document but you must consider that each file require a call to the web service. In more cases, the best solution will be a more complex but unique xml data file.
Because it’s designed to be used from an application, there is any user interface.

How to deploy

Just unzip the package and add it in IIS as you want.

How to use

First, just add a service reference on it. Service reference path depend on how you are configure your IIS web application for it.

The best to explain how use is show a sample.

Sample to merge document and xml data

static void Main(string[] args)
{
string dataXml = File.ReadAllText(@"d:\test.xml");
byte[] doc = File.ReadAllBytes(@"d:\test.docx");
MetadataServicesClient srv = new MetadataServicesClient();
byte[] output = srv.Merge(doc, dataXml);
srv.Close();
File.WriteAllBytes(@"d:\test.docx", output);
}

Sample to retrieve xml data from document

static void Main(string[] args)
{
byte[] doc = File.ReadAllBytes(@"d:\test.docx");
MetadataServicesClient srv = new MetadataServicesClient();
Console.WriteLine(srv.Extract(doc, "http://schemas.microsoft.com/customxml/datastore"));
srv.Close();
Console.WriteLine("Appuyez sur une touche pour continuer");
Console.ReadKey();
}

Last edited Oct 10, 2012 at 6:42 AM by jab63, version 1

Comments

No comments yet.