Wednesday, May 09, 2007

How to change the NameSpace inside InfoPath 2007 Template

When you design an InfoPath 2003 or InfoPath 2007 from an existing schema. The namespace of the schema is going to be hardcoded inside the manifest.xsf of the XSN package. There is very litle you can do to change this namespace.

This namespace will be the one that is always going to be sent across when you submit the form to a web service. The namespace will be stored in the xmlns:ns1= node.

Even if you remove every single element from the InfoPath form, this reference will be still be inside the form. You can verify this by saving the files from the designer:

In InfoPath 2007: Select File, then select Save as Source Files. Select a directory where you will like to put those files and click on the OK button to execute it.



In InfoPath 2003: Select File, then select Extract Form Files.... Select a directory where you will extract the source files and click on the OK button.



In each directory you will find a bunch of files. The one we are after is the manifest.xsf. This manifest is the one that has the namespace hardcoded into it. However, there is not an easy way to change the manifest and then put it back into the InfoPath Template.

A little trick to try is to change the extension of the template. For instance, if the Infopath template name is Template.XSN, you can change it to Template.CAB. ;) Thanks Monish for this tip.!

Now you can see all of the files inside the CAB archive. You can extract the manifest file out of it and change it, then put it back into the archive. Rename file back to XSN, and you will be done.!




neat.

2 comments:

Marco Diaz said...

Hola, espero puedas darme una mano.
Mira tengo 2 formulario infopath que tiene una estructura similar llamada cabecera, para estoy he construido una clase para poder serializarlo.
el primero cuando cada formulario maneja name espace diferente:
el primer formulario:
el segnudo formulario:
entonces pense que la solucion podria ser poniendo un mismo namespace, uno de ellos si funciona muy bien, pero el otro tiene problemas.
Ahh esa estructura la uso para mandar a un web services.
Haber si me das una ayuda. gracias

Marco Diaz:
http://marcodiazjr.blogspot.com/
Saludos.

Arnulfo Wing said...

Marco. No estoy seguro de la implementacion que estas haciendo. Te sugeriria que utilizes el XmlNameSpaceManager en tu XMLDocument para acceder cada uno de los namespaces dentro de tu InfoPath. Checkea este link para mas informacion: http://msdn2.microsoft.com/en-us/library/d6730bwt.aspx

Si necesitas mas ayuda, mandame un email si quieres, y te tratare de ayudar mas.

gracias.

A>Wing