I am trying to use a URL request (via WebRequest.Create) to programmatically retrieve an InfoPath XML document from a document library using the following VB code:
Dim formXml As String = ""
Dim req As WebRequest = WebRequest.Create("http://server/doclib/file.xml")
req.Credentials = CredentialCache.DefaultNetworkCredentials
req.Method = "GET"
Dim resp As WebResponse = req.GetResponse()
Using s As Stream = resp.GetResponseStream(), sr As New StreamReader(s)
formXml = sr.ReadToEnd()
End Using
This works as long as the form template is not browser-enabled. However, if the form template is browser-enabled and the document library is set to "Display as a web page", the request always returns the HTML generated by Forms Services.
Is there an alternate way to programmatically retrieve the actual XML for the document without using the SharePoint web services or object model?