Hi there,
currently i am writing a little bit of code in Infopath to receive specific data from a SharePoint server. But first things first.
I am using InfoPath 2007 and Sharepoint 2007. Language C#
You can put this thread into various subforums such as Webservise, Code or Data Connections, but i think with Code i hit the best spot.
The situation is this:
I have one Sharepoint formlibrary where the forms will be uploaded and the task list with the tasks from various workflows working on the forms. What I am trying to do is to display the actual tasks of the form in the form itself. For this I wrote some code which will get the ID of the form out of the library. The code compares the ID with the WorkflowItemId in the tasklist and so the code gets the actual tasks for the form. After this the code writes the tasks into the form. Thats for the theory.
Now whats not working?
I want to get the ID of the form over a webrequest with a REST url. In the Browser its working fine.
The url looks like this:
URL = http://Sharepointadress/_vti_bin/owssvr.dll?Cmd=Display&List={LISTGUID}&XMLDATA=TRUE&FilterField1=Title&FilterValue1=FORMNAME&noredirect=true&Query=ID
With this i will get exactly one or zero IDs. Zero when the form does not exist.
When i am trying this with my webrequest in C# it works as long as i am trying this on my dev machine. When the form is published on the target Sharepoint and i open it on another machine in the same domain, i will get an error. I have located the line of code which is responsible for that, but i have not yet found a solution or a workarount. The line of code lies in the webrequest.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL);
req.PreAuthenticate = true;
req.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
req.Method = "GET";
req.UserAgent = "MSIE 8.0";
req.CookieContainer = new CookieContainer();
req.Credentials = CredentialCache.DefaultNetworkCredentials; //When i am commenting this line out i will get a 401 error, if its not commented out ill get a system.security.SecurityException
resp = (HttpWebResponse)req.GetResponse();
RespStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(RespStream);
string xml = reader.ReadToEnd();
I think the form does not have the rights to send the user credentials to the sharepoint. But why? It is in the same Domain. Is there a solution for this Problem? I worked already for 3 days on this and I havn't found a solution. Or is there anotherway to get the ID or the WorkflowItemId (works also with a webrequest, same error) without producing too much overhead in the dataconnection? For example modifying the location of the xml file from a xml dataconnection. Or something like that.
Setting the form to fulltrust is not an option!
Best regards
Oliver D.
PS: Maybe the full error text would be helpful.
http://imageshack.us/photo/my-images/824/errorxhu.png/