<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.officezealot.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Office Server 2007 Ramblings : VSTA</title><link>http://blogs.officezealot.com/bsandeman/archive/tags/VSTA/default.aspx</link><description>Tags: VSTA</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>Validation</title><link>http://blogs.officezealot.com/bsandeman/archive/2006/08/30/12859.aspx</link><pubDate>Wed, 30 Aug 2006 18:50:00 GMT</pubDate><guid isPermaLink="false">a446e06f-2cc4-48dd-a534-c024bd1e2687:12859</guid><dc:creator>bsandeman</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.officezealot.com/bsandeman/comments/12859.aspx</comments><wfw:commentRss>http://blogs.officezealot.com/bsandeman/commentrss.aspx?PostID=12859</wfw:commentRss><wfw:comment>http://blogs.officezealot.com/bsandeman/rsscomments.aspx?PostID=12859</wfw:comment><description>Today I have started to try to add validation to my form, the requirement here is for the validation to be performed by Biztalk Orchestrations, therefore I need to communicate with Biztalk via a URL.
&lt;br&gt;
The problem with this is that the InfoPath client (VSTA) does not allow you to sign the code with a certificate and therefore you cannot use an HttpRequest object to communicate with Biztalk in this way.  I have therefore attempted to create a VSTO project based on my InfoPath form, but it keeps giving me the following error....
&lt;p&gt;
&lt;img src="http://blogs.officezealot.com/photos/bsandeman/images/20071/original.aspx"&gt;
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;The strange thing here is that it appears to be referencing a version of InfoPath that I have never installed (2003), I've only ever used 2007 beta2, so quite what Visual Studio thinks it's doing, is beyond me.....
&lt;/p&gt;&lt;hr&gt;
hmmmmm, interesting....&lt;br&gt;
I seem to have managed to convince VSTO to load my form (I still get the error when I open the project), but I can now see my form in VSTO and I can design it etc.&lt;br&gt;
I did this by creating a new project for an InfoPath form in VSTO and then replacing the contents of the folder "InfoPath Form Template" with all the contents of the original XSN file (extracted the files from it by renaming .xsn to .cab).  I also pasted the code from within VSTA direct into FormCode.cs within my new project, I had to do this as it's compiled into an Assembly by VSTA when it goes into the XSN file, therefore it's useless to VSTO unless it has the actual code.  Just by pasting it in, the code seems to link up with the form without any problems....
However, I cannot test it as it gives me 2 errors when I try to execute it as follows :&lt;br&gt;
1. The form template cannot be updated because it is read-only&lt;br&gt;
2. The operation could not be completed&lt;br&gt;
&lt;p&gt;Subsequent executions result in the error &lt;i&gt;"The debugger cannot continue running the process.  Operation not supported.  Unknown error: 0x80043573."&lt;/i&gt;&lt;br&gt;&lt;/p&gt;
Also if I try to save the manifest.xsf file it gives me the error &lt;i&gt;"InfoPath cannot save the following form: Template1 - The form is read-only."&lt;/i&gt;
&lt;br&gt;&lt;br&gt;
funky....&lt;br&gt;&lt;br&gt;For your info, my code is....
&lt;pre class="code"&gt;        //********** Biztalk Validation **********//&lt;br&gt;        private String bizSupplierIURL = "http://vm-devbiztalk01.dev.com:8080/BTSHTTPReceive.dll?SupplierInquiry";&lt;br&gt;&lt;br&gt;        public bool supplierExists(string sSupplierID)&lt;br&gt;        {&lt;br&gt;            return supplierExists(bizSupplierIURL, sSupplierID, "", "");&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        public bool supplierExists(string sURL, string sSupplierID, string sNameLike, string sAddrLike)&lt;br&gt;        {&lt;br&gt;&lt;br&gt;            //Create http web request&lt;br&gt;            HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(sURL);&lt;br&gt;            httpRequest.Method = "POST";&lt;br&gt;            httpRequest.ContentType = "application/xml";&lt;br&gt;&lt;br&gt;            //build xml request&lt;br&gt;            XmlTextWriter xmlWriter = new XmlTextWriter(httpRequest.GetRequestStream(), System.Text.Encoding.UTF8);&lt;br&gt;            xmlWriter.WriteStartDocument();&lt;br&gt;            xmlWriter.WriteStartElement("ns0:SupplierInquiry");&lt;br&gt;            xmlWriter.WriteAttributeString("xmlns", "ns0", null, "urn:test-dev-com.supplierinquiry.v1");&lt;br&gt;            xmlWriter.WriteStartElement("Request");&lt;br&gt;            xmlWriter.WriteElementString("SupplierID", sSupplierID);&lt;br&gt;            xmlWriter.WriteElementString("SupplierNameLike", sNameLike);&lt;br&gt;            xmlWriter.WriteElementString("SupplierAddressLike", sAddrLike);&lt;br&gt;            xmlWriter.WriteEndElement();&lt;br&gt;            xmlWriter.WriteEndElement();&lt;br&gt;            xmlWriter.Close();&lt;br&gt;&lt;br&gt;            //send the request&lt;br&gt;            HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();&lt;br&gt;&lt;br&gt;            //get the response&lt;br&gt;            StreamReader streamResponse = new StreamReader(httpResponse.GetResponseStream());&lt;br&gt;&lt;br&gt;            XmlDocument xdoc = new XmlDocument();&lt;br&gt;            xdoc.Load(streamResponse);&lt;br&gt;&lt;br&gt;            XmlNamespaceManager xnm = new XmlNamespaceManager(xdoc.NameTable);&lt;br&gt;            xnm.AddNamespace("ns0", "urn:test-dev-com.supplierinquiry.v1");&lt;br&gt;            XmlNodeList xtest = xdoc.SelectNodes("//ns0:SupplierInquiry/Response/Suppliers", xnm);&lt;br&gt;&lt;br&gt;            return (xtest.Count &amp;gt; 0);&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        //*************** Validating Events ***************//&lt;br&gt;        public void Order_SupplierNumber_Validating(object sender, XmlValidatingEventArgs e)&lt;br&gt;        {&lt;br&gt;            if (!supplierExists(e.OldValue))&lt;br&gt;            {&lt;br&gt;                XPathNavigator XPN = this.MainDataSource.CreateNavigator().SelectSingleNode(e.Match);&lt;br&gt;                Errors.Add(XPN, "Supplier", "Supplier is invalid");&lt;br&gt;            }&lt;br&gt;        }&lt;br&gt;&lt;/pre&gt;&lt;img src="http://blogs.officezealot.com/aggbug.aspx?PostID=12859" width="1" height="1"&gt;</description><category domain="http://blogs.officezealot.com/bsandeman/archive/tags/InfoPath/default.aspx">InfoPath</category><category domain="http://blogs.officezealot.com/bsandeman/archive/tags/VSTA/default.aspx">VSTA</category><category domain="http://blogs.officezealot.com/bsandeman/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.officezealot.com/bsandeman/archive/tags/Bugs/default.aspx">Bugs</category><category domain="http://blogs.officezealot.com/bsandeman/archive/tags/Validation/default.aspx">Validation</category></item></channel></rss>