Infopath docs

  • Thread starter Thread starter travisj
  • Start date Start date
T

travisj

I have a question regarding Infopath and Sharepoint. We have a
sharepoint site set up with a few Infopath document libraries, how can
I open,modify, and save the Infopath documents stored therein?

Currently I have the following:

XmlDocument doc = new XmlDocument();
doc.Load("http://bomserver2:74/TestSharePoint/Library/0000.xml");

The Sharepoint site is returning a (401) Unathorized error when loading
the document. Of course I could set the Sharepoint site to allow
anonymous access to these libraries but that may not be the desired
solution. So I guess more specifically I need to know how to
propmatically specify user credentials when loading/saving xml
documents to Sharepoint. Hope I explained that thoroughly enough for
someone to be able to provide some help. Thanks
 
I found the answer to my own question. I will post it here so others
who may be searching for this kind of info can find it.

loading the XML data:

XmlDocument doc = new XmlDocument();
HttpWebRequest req = (HttpWebRequest)WebRequest.
Create("http://bomserver2:74/TestSharePoint/Library/0000.xml");

req.Credentials = CredentialCache.DefaultNetworkCredentials;
Stream s = req.GetResponse().GetResponseStream();
XmlTextReader reader = new XmlTextReader(s);
doc.Load(reader);

// you now have an XML document that you can do with as you please
//saving the XML document back at the share point site requires
//installation of a custom web service however ... see
//http://msdn.microsoft.com/library/d.../html/odc_writingcustomwebservicesforsppt.asp
//
// After installing the sample web service and adding the web
//reference to your project one should be able to utillize
//the UploadDocument service after converting the
//XML contents into a byte array

string result = customService.UploadDocument("a.xml", byteArray,
"http://bomserver2:74/TestSharePoint/Library");
MessageBox.Show(result);
 
Back
Top